diff options
| author | Stefan Boberg <[email protected]> | 2021-05-13 18:22:09 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-13 18:22:09 +0200 |
| commit | 3672bfa998f932bb306e88bf1202a548bb463f24 (patch) | |
| tree | 4b6b90bef9a42f9cc1a34660d248d985d66177e5 /zenstore/filecas.cpp | |
| parent | Implemented move-in-place for large CAS payloads (diff) | |
| download | zen-3672bfa998f932bb306e88bf1202a548bb463f24.tar.xz zen-3672bfa998f932bb306e88bf1202a548bb463f24.zip | |
Added logic to guard against accidental file move in file CAS fast path
Now verifies the chunk is referencing an entire file before moving it into place
Diffstat (limited to 'zenstore/filecas.cpp')
| -rw-r--r-- | zenstore/filecas.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index 0011ddec6..1e9b50e63 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -63,8 +63,11 @@ FileCasStrategy::MakeShardedPath(WideStringBuilderBase& ShardedPath, const IoHas CasStore::InsertResult FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash) { + // File-based chunks have special case handling whereby we move the file into + // place in the file store directory, thus avoiding unnecessary copying + IoBufferFileReference FileRef; - if (Chunk.GetFileReference(/* out */ FileRef)) + if (Chunk.IsWholeFile() && Chunk.GetFileReference(/* out */ FileRef)) { size_t Shard2len = 0; ExtendableWideStringBuilder<128> ShardedPath; |