diff options
| author | EPICGAMES\thierry.begin <[email protected]> | 2024-04-08 10:43:16 -0400 |
|---|---|---|
| committer | EPICGAMES\thierry.begin <[email protected]> | 2024-04-08 10:43:16 -0400 |
| commit | b35e1258a043cab06950b2453f434861d99b918a (patch) | |
| tree | 695737774fa08ebaa0e32a9f95cb0247c34b3dc3 /src/zenstore/filecas.cpp | |
| parent | Add docker support (diff) | |
| parent | Merge pull request #41 from ue-foundation/zs/import-oplog-clean (diff) | |
| download | zen-tb/docker.tar.xz zen-tb/docker.zip | |
Merge branch 'main' of https://github.ol.epicgames.net/ue-foundation/zen into tb/dockertb/docker
Diffstat (limited to 'src/zenstore/filecas.cpp')
| -rw-r--r-- | src/zenstore/filecas.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp index 428183827..0f3e2ab5a 100644 --- a/src/zenstore/filecas.cpp +++ b/src/zenstore/filecas.cpp @@ -729,19 +729,28 @@ FileCasStrategy::FindChunk(const IoHash& ChunkHash) ZEN_ASSERT(m_IsInitialized); + uint64_t ExpectedSize = 0; { RwLock::SharedLockScope _(m_Lock); - if (!m_Index.contains(ChunkHash)) + if (auto It = m_Index.find(ChunkHash); It != m_Index.end()) + { + ExpectedSize = It->second.Size; + } + else { return {}; } } - ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash); - + ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash); RwLock::SharedLockScope _(LockForHash(ChunkHash)); - return IoBufferBuilder::MakeFromFile(Name.ShardedPath.c_str()); + if (IoBuffer Chunk = IoBufferBuilder::MakeFromFile(Name.ShardedPath.c_str()); Chunk.GetSize() == ExpectedSize) + { + return Chunk; + } + + return {}; } bool @@ -1201,7 +1210,7 @@ FileCasStrategy::MakeIndexSnapshot() EntryCount = Entries.size(); m_LogFlushPosition = IndexLogPosition; } - catch (std::exception& Err) + catch (const std::exception& Err) { ZEN_WARN("snapshot FAILED, reason: '{}'", Err.what()); |