aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-08 00:24:18 +0200
committerStefan Boberg <[email protected]>2021-10-08 00:24:18 +0200
commit57d204296359525fe640b4d96e5c62322c7a73c9 (patch)
treebfe3848e83baef6b2a765ad281141498a9e9ccd0
parentAdded shell32.dll to delay load list since it's only needed when no directory... (diff)
downloadzen-57d204296359525fe640b4d96e5c62322c7a73c9.tar.xz
zen-57d204296359525fe640b4d96e5c62322c7a73c9.zip
filecas: Added handling of error when a rename is attempted but the target already exists
-rw-r--r--zenstore/filecas.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index ee641b80a..e45650f27 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -183,8 +183,15 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
return CasStore::InsertResult{.New = true};
}
+ const DWORD LastError = GetLastError();
+
+ if ((LastError == ERROR_FILE_EXISTS) || (LastError == ERROR_ALREADY_EXISTS))
+ {
+ return CasStore::InsertResult{.New = false};
+ }
+
ZEN_WARN("rename of CAS payload file failed ('{}'), falling back to regular write for insert of {}",
- GetLastErrorAsString(),
+ GetSystemErrorAsString(LastError),
ChunkHash);
DeletePayloadFileOnClose();