mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[wpilibj] DataLogManager: Fix behavior when low on space (#6486)
Uses getUsableSpace in Java, matching how C++ determines available space (C++ calls it available, but they mean the same thing.) This fixes a bug where logs wouldn't get deleted due to incorrect available space detection. The DataLog thread now also checks if the state was marked as stopped after a call to StartLogFile.
This commit is contained in:
@@ -269,7 +269,7 @@ public final class DataLogManager {
|
||||
// based on free disk space, scan for "old" FRC_*.wpilog files and remove
|
||||
{
|
||||
File logDir = new File(m_logDir);
|
||||
long freeSpace = logDir.getFreeSpace();
|
||||
long freeSpace = logDir.getUsableSpace();
|
||||
if (freeSpace < kFreeSpaceThreshold) {
|
||||
// Delete oldest FRC_*.wpilog files (ignore FRC_TBD_*.wpilog as we just created one)
|
||||
File[] files =
|
||||
@@ -304,7 +304,7 @@ public final class DataLogManager {
|
||||
+ freeSpace / 1000000
|
||||
+ " MB of free space remaining! Logs will get deleted below "
|
||||
+ kFreeSpaceThreshold / 1000000
|
||||
+ " MB of free space."
|
||||
+ " MB of free space. "
|
||||
+ "Consider deleting logs off the storage device.",
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -463,6 +463,9 @@ void DataLog::WriterThreadMain(std::string_view dir) {
|
||||
lock.unlock();
|
||||
StartLogFile(state);
|
||||
lock.lock();
|
||||
if (m_state == kStopped) {
|
||||
continue;
|
||||
}
|
||||
if (state.f != fs::kInvalidFile) {
|
||||
// Emit start and schema data records
|
||||
for (auto&& entryInfo : m_entries) {
|
||||
|
||||
Reference in New Issue
Block a user