diff options
Diffstat (limited to 'zenstore/filecas.cpp')
| -rw-r--r-- | zenstore/filecas.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index d0a8ad849..9825f225a 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -124,7 +124,7 @@ FileCasStrategy::Initialize(const std::filesystem::path& RootDirectory, bool IsN } CasStore::InsertResult -FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) +FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore::InsertMode Mode) { ZEN_ASSERT(m_IsInitialized); @@ -132,6 +132,16 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) ZEN_ASSERT(Chunk.GetContentType() == ZenContentType::kCompressedBinary); #endif + if (Mode == CasStore::InsertMode::kCopyOnly) + { + ShardingHelper Name(m_RootDirectory.c_str(), ChunkHash); + if (std::filesystem::is_regular_file(Name.ShardedPath.ToPath())) + { + return {.New = false}; + } + return InsertChunk(Chunk.Data(), Chunk.Size(), ChunkHash); + } + // File-based chunks have special case handling whereby we move the file into // place in the file store directory, thus avoiding unnecessary copying @@ -153,6 +163,8 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) if (!Success) { + // TODO: We should provide information to this function to tell it if the payload is temporary or not and if we are allowed + // to delete it. ZEN_WARN("Failed to flag temporary payload file '{}' for deletion: '{}'", PathFromHandle(ChunkFileHandle), GetLastErrorAsString()); @@ -294,6 +306,7 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) ChunkHash); DeletePayloadFileOnClose(); + #elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC std::filesystem::path SourcePath = PathFromHandle(FileRef.FileHandle); std::filesystem::path DestPath = Name.ShardedPath.c_str(); |