aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-03-31 18:16:41 +0200
committerDan Engelbrecht <[email protected]>2022-03-31 18:16:41 +0200
commit1cbb8a3ad2f001d8967ff6533aabe9bdee890f5e (patch)
treef030135902687e1153bc789dc0c58a1e892fcf56 /zenstore/compactcas.cpp
parentlogging cleanup (diff)
downloadzen-1cbb8a3ad2f001d8967ff6533aabe9bdee890f5e.tar.xz
zen-1cbb8a3ad2f001d8967ff6533aabe9bdee890f5e.zip
leave legacy files so we can switch back to older version without crashing
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp18
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());