aboutsummaryrefslogtreecommitdiff
path: root/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-11-18 11:35:13 +0100
committerGitHub <[email protected]>2022-11-18 02:35:13 -0800
commit55225621f018904abf7e212320bb784dc64f8ac3 (patch)
tree3fb962e9e0553448f9d42612bb078ff072308e1c /zenstore/filecas.cpp
parentmove BasicFile to zenutil to remove zenstore dependency from zen command (#190) (diff)
downloadzen-55225621f018904abf7e212320bb784dc64f8ac3.tar.xz
zen-55225621f018904abf7e212320bb784dc64f8ac3.zip
Add `import-project` and `export-project` (#183)
* Add `import-project` and `export-project` command line parsing
Diffstat (limited to 'zenstore/filecas.cpp')
-rw-r--r--zenstore/filecas.cpp15
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();