aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/filecas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenstore/filecas.cpp')
-rw-r--r--src/zenstore/filecas.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp
index 0d742d7e1..fe568a487 100644
--- a/src/zenstore/filecas.cpp
+++ b/src/zenstore/filecas.cpp
@@ -795,6 +795,21 @@ FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, IoBuffer&&
}
void
+FileCasStrategy::IterateChunks(std::function<void(const IoHash& Hash, uint64_t Size)>&& Callback)
+{
+ ZEN_TRACE_CPU("FileCas::IterateChunks");
+
+ ZEN_ASSERT(m_IsInitialized);
+
+ RwLock::SharedLockScope _(m_Lock);
+ for (const auto& It : m_Index)
+ {
+ const IoHash& NameHash = It.first;
+ Callback(NameHash, It.second.Size);
+ }
+}
+
+void
FileCasStrategy::Flush()
{
ZEN_TRACE_CPU("FileCas::Flush");
@@ -927,7 +942,7 @@ FileCasStrategy::CollectGarbage(GcContext& GcCtx)
{
ZEN_TRACE_CPU("FileCas::CollectGarbage::Filter");
- IterateChunks([&](const IoHash& Hash, IoBuffer&& Payload) {
+ IterateChunks([&](const IoHash& Hash, uint64_t Size) {
bool KeepThis = false;
CandidateCas[0] = Hash;
GcCtx.FilterCids(CandidateCas, [&](const IoHash& Hash) {
@@ -935,16 +950,14 @@ FileCasStrategy::CollectGarbage(GcContext& GcCtx)
KeepThis = true;
});
- const uint64_t FileSize = Payload.GetSize();
-
if (!KeepThis)
{
ChunksToDelete.push_back(Hash);
- ChunksToDeleteBytes.fetch_add(FileSize);
+ ChunksToDeleteBytes.fetch_add(Size);
}
++ChunkCount;
- ChunkBytes.fetch_add(FileSize);
+ ChunkBytes.fetch_add(Size);
});
}