From c028afcc305457fc24ffc62b9b7197f44ba45689 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 4 Sep 2024 10:03:38 +0200 Subject: clean cache slog files on startup (#143) - Bugfix: If we fail to move a temporary file into place, try to re-open the file so we clean it up - Improvement: Clean up cache bucket log files at startup as we store the matching information in the index snapshot for the bucket --- src/zenutil/basicfile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/zenutil/basicfile.cpp') diff --git a/src/zenutil/basicfile.cpp b/src/zenutil/basicfile.cpp index 174125069..575d153b2 100644 --- a/src/zenutil/basicfile.cpp +++ b/src/zenutil/basicfile.cpp @@ -560,6 +560,13 @@ TemporaryFile::MoveTemporaryIntoPlace(std::filesystem::path FinalFileName, std:: BasicFile::Close(); std::filesystem::rename(m_TempPath, FinalFileName, Ec); + + if (Ec) + { + // Try to re-open the temp file so we clean up after us when TemporaryFile is destructed + std::error_code DummyEc; + Open(m_TempPath, BasicFile::Mode::kWrite, DummyEc); + } } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3