[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:
Gold856
2024-04-21 23:34:05 -04:00
committed by GitHub
parent 7bc0380694
commit 3e5187ff32
2 changed files with 5 additions and 2 deletions

View File

@@ -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);
}