diff options
Diffstat (limited to 'zenstore/cidstore.cpp')
| -rw-r--r-- | zenstore/cidstore.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp index 3460e1df2..4e5188f1c 100644 --- a/zenstore/cidstore.cpp +++ b/zenstore/cidstore.cpp @@ -36,14 +36,29 @@ struct CidStore::CidState IoBuffer FindChunkByCid(const IoHash& DecompressedId) { - if (auto It = m_CidMap.find(DecompressedId); It != m_CidMap.end()) + IoHash CompressedHash; { - return m_CasStore.FindChunk(It->second); + RwLock::SharedLockScope _(m_Lock); + if (auto It = m_CidMap.find(DecompressedId); It != m_CidMap.end()) + { + CompressedHash = It->second; + } + } + + if (CompressedHash != IoHash::Zero) + { + return m_CasStore.FindChunk(CompressedHash); } return IoBuffer(); } + bool ContainsChunk(const IoHash& DecompressedId) + { + RwLock::SharedLockScope _(m_Lock); + return m_CidMap.find(DecompressedId) != m_CidMap.end(); + } + void InitializeIndex(const std::filesystem::path& RootDir) { zen::CreateDirectories(RootDir); @@ -84,6 +99,12 @@ CidStore::FindChunkByCid(const IoHash& DecompressedId) return m_Impl->FindChunkByCid(DecompressedId); } +bool +CidStore::ContainsChunk(const IoHash& DecompressedId) +{ + return m_Impl->ContainsChunk(DecompressedId); +} + void CidStore::Flush() { |