From 347153218dd09e3806e5b27eb51f538768f27035 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 26 Sep 2025 10:26:34 +0200 Subject: new append op rpc method (#511) - Feature: New `/prj/{project}/{oplog}/rpc` endpoint method `appendops` to send an array of oplog ops and receiving a list of `need` for attachments not present - Feature: Added `usingtmpfiles` boolean field to `/prj/{project}/{oplog}/rpc` method `putchunks` to be explicit about allowing move of temp attachment files - Improvement: Added additional validation of compact binary objects when reading from disk/receiving from client - Improvement: Windows: Added fallback code to use standard `MoveFile` api when rename via `SetFileInformationByHandle` fails in `MoveToFile` (used by filecas) --- src/zencore/filesystem.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/zencore/filesystem.cpp') diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp index 5125beeca..8e6f5085f 100644 --- a/src/zencore/filesystem.cpp +++ b/src/zencore/filesystem.cpp @@ -1290,6 +1290,27 @@ MoveToFile(std::filesystem::path Path, IoBuffer Data) zen::CreateDirectories(Path.parent_path()); Success = SetFileInformationByHandle(ChunkFileHandle, FileRenameInfo, RenameInfo, BufferSize); } + if (!Success && (LastError == ERROR_ACCESS_DENIED)) + { + // Fallback to regular rename + std::error_code Ec; + std::filesystem::path SourcePath = PathFromHandle(FileRef.FileHandle, Ec); + if (!Ec) + { + auto NativeSourcePath = SourcePath.native().c_str(); + auto NativeTargetPath = Path.native().c_str(); + Success = ::MoveFile(NativeSourcePath, NativeTargetPath); + if (!Success) + { + LastError = GetLastError(); + if (LastError == ERROR_PATH_NOT_FOUND) + { + zen::CreateDirectories(Path.parent_path()); + Success = ::MoveFile(NativeSourcePath, NativeTargetPath); + } + } + } + } } Memory::Free(RenameInfo); if (!Success) -- cgit v1.2.3