diff options
Diffstat (limited to 'zenstore/filecas.cpp')
| -rw-r--r-- | zenstore/filecas.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index 3c4add82a..62600eae6 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -90,7 +90,16 @@ FileCasStrategy::Initialize(bool IsNewStore) m_CasLog.Open(m_Config.RootDirectory / "cas.ulog", IsNewStore); - m_CasLog.Replay([&](const FileCasIndexEntry& Entry) { m_TotalSize.fetch_add(Entry.Size); }); + m_CasLog.Replay([&](const FileCasIndexEntry& Entry) { + if (Entry.IsFlagSet(FileCasIndexEntry::kTombStone)) + { + m_TotalSize.fetch_sub(Entry.Size, std::memory_order_relaxed); + } + else + { + m_TotalSize.fetch_add(Entry.Size, std::memory_order_relaxed); + } + }); } CasStore::InsertResult @@ -400,7 +409,7 @@ FileCasStrategy::DeleteChunk(const IoHash& ChunkHash, std::error_code& Ec) if (!Ec) { m_TotalSize.fetch_sub(FileSize); - m_CasLog.Append({.Key = ChunkHash, .Size = -static_cast<int64_t>(FileSize)}); + m_CasLog.Append({.Key = ChunkHash, .Flags = FileCasIndexEntry::kTombStone, .Size = static_cast<int64_t>(FileSize)}); } } |