diff options
| author | Per Larsson <[email protected]> | 2021-12-14 09:41:04 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-12-14 09:41:04 +0100 |
| commit | 5f8136b25040046c466c95cbec3874594ff91d0c (patch) | |
| tree | b6cdbf23a5074c18ed7565e8c81709a9df350c0c /zenstore/cidstore.cpp | |
| parent | Remove Cid to CAS chunk mapping after GC. (diff) | |
| download | zen-5f8136b25040046c466c95cbec3874594ff91d0c.tar.xz zen-5f8136b25040046c466c95cbec3874594ff91d0c.zip | |
Fixed bug in z$ service returning partial cache records and enable small object GC by default.
Diffstat (limited to 'zenstore/cidstore.cpp')
| -rw-r--r-- | zenstore/cidstore.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp index 33dc216b5..c5396cff3 100644 --- a/zenstore/cidstore.cpp +++ b/zenstore/cidstore.cpp @@ -107,20 +107,17 @@ struct CidStore::Impl bool ContainsChunk(const IoHash& DecompressedId) { - RwLock::SharedLockScope _(m_Lock); - // Note that we do not check CAS here. This is optimistic but usually - // what we want. - auto It = m_CidMap.find(DecompressedId); + IoHash CasHash = IoHash::Zero; - if (It == m_CidMap.end()) { - // Not in map - return false; + RwLock::SharedLockScope _(m_Lock); + if (const auto It = m_CidMap.find(DecompressedId); It != m_CidMap.end()) + { + CasHash = It->second; + } } - ZEN_ASSERT(It->second != IoHash::Zero); - - return true; + return CasHash != IoHash::Zero ? m_CasStore.ContainsChunk(CasHash) : false; } void InitializeIndex(const std::filesystem::path& RootDir) |