[wpiutil] DataLogBackgroundWriter: Normalize empty path name (#7151)

An empty path isn't valid on it's own, so fs::space always returns an error. This results in UINT_MAX bytes being used instead of the actual free space, which means a default constructed DataLogBackgroundWriter won't stop for low space.

Using "." instead makes the directory path the current working directory, which is the desired behavior
This commit is contained in:
Ryan Blue
2024-10-03 15:32:09 -04:00
committed by GitHub
parent a8a5d1609b
commit 83615c6024

View File

@@ -176,7 +176,8 @@ static std::string MakeRandomFilename() {
}
struct DataLogBackgroundWriter::WriterThreadState {
explicit WriterThreadState(std::string_view dir) : dirPath{dir} {}
explicit WriterThreadState(std::string_view dir)
: dirPath{dir.empty() ? "." : dir} {}
WriterThreadState(const WriterThreadState&) = delete;
WriterThreadState& operator=(const WriterThreadState&) = delete;
~WriterThreadState() { Close(); }