diff options
| author | Dan Engelbrecht <[email protected]> | 2022-03-31 18:16:41 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-03-31 18:16:41 +0200 |
| commit | 1cbb8a3ad2f001d8967ff6533aabe9bdee890f5e (patch) | |
| tree | f030135902687e1153bc789dc0c58a1e892fcf56 | |
| parent | logging cleanup (diff) | |
| download | zen-1cbb8a3ad2f001d8967ff6533aabe9bdee890f5e.tar.xz zen-1cbb8a3ad2f001d8967ff6533aabe9bdee890f5e.zip | |
leave legacy files so we can switch back to older version without crashing
| -rw-r--r-- | zenstore/compactcas.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp index c2ca5b78f..0c4a84dd1 100644 --- a/zenstore/compactcas.cpp +++ b/zenstore/compactcas.cpp @@ -594,15 +594,23 @@ namespace { } } } + + BlockFile.Close(); LegacyCasLog.Close(); CasLog.Close(); if (CleanSource) { - std::filesystem::remove(LegacyLogPath); - BlockFile.Close(); - std::filesystem::remove(LegacySobsPath); - std::filesystem::remove(LegacySidxPath); + // Older versions of CasContainerStrategy expects the legacy files to exist if it can find + // a CAS manifest and crashes on startup if they don't. + // In order to not break startup when switching back an older version, lets just reset + // the legacy data files to zero length. + BasicFile LegacyLog; + LegacyLog.Open(LegacyLogPath, BasicFile::EMode::kTruncate); + BasicFile LegacySobs; + LegacySobs.Open(LegacySobsPath, BasicFile::EMode::kTruncate); + BasicFile LegacySidx; + LegacySidx.Open(LegacySidxPath, BasicFile::EMode::kTruncate); } return Result; } @@ -1493,7 +1501,7 @@ CasContainerStrategy::OpenContainer(bool IsNewStore) MakeSnapshot = !LogEntries.empty(); } - if (std::filesystem::is_regular_file(LegacyLogPath)) + if (std::filesystem::is_regular_file(LegacyLogPath) && std::filesystem::file_size(LegacyLogPath) > 0) { std::unordered_set<IoHash, IoHash::Hasher> ExistingChunks; ExistingChunks.reserve(m_LocationMap.size()); |