aboutsummaryrefslogtreecommitdiff
path: root/zenstore
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore')
-rw-r--r--zenstore/compactcas.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index c49bfc8bf..63e5168c7 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -311,25 +311,24 @@ CasContainerStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
IoBuffer
CasContainerStrategy::FindChunk(const IoHash& ChunkHash)
{
- RwLock::SharedLockScope _(m_LocationMapLock);
-
- if (auto KeyIt = m_LocationMap.find(ChunkHash); KeyIt != m_LocationMap.end())
+ std::shared_ptr<ChunkBlock> ChunkBlock;
+ CasLocation Location;
{
- CasLocation Location = KeyIt->second.Get(m_PayloadAlignment);
-
- if (auto BlockIt = m_ChunkBlocks.find(Location.BlockIndex); BlockIt != m_ChunkBlocks.end())
+ RwLock::SharedLockScope _(m_LocationMapLock);
+ auto KeyIt = m_LocationMap.find(ChunkHash);
+ if (KeyIt == m_LocationMap.end())
{
- if (BlockIt->second) // This happens if the data associated with the block is not found - ie the ucas file is deleted but
- // the index not updated
- {
- return BlockIt->second->GetChunk(Location.Offset, Location.Size);
- }
+ return IoBuffer();
}
+ Location = KeyIt->second.Get(m_PayloadAlignment);
+ auto BlockIt = m_ChunkBlocks.find(Location.BlockIndex);
+ if (BlockIt == m_ChunkBlocks.end())
+ {
+ return IoBuffer();
+ }
+ ChunkBlock = BlockIt->second;
}
-
- // Not found
-
- return IoBuffer();
+ return ChunkBlock->GetChunk(Location.Offset, Location.Size);
}
bool