aboutsummaryrefslogtreecommitdiff
path: root/src/zencore
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-09-26 10:26:34 +0200
committerGitHub Enterprise <[email protected]>2025-09-26 10:26:34 +0200
commit347153218dd09e3806e5b27eb51f538768f27035 (patch)
tree81ef102cc116ed2c751e1af91d83db32ffa8d369 /src/zencore
parentMerge pull request #509 from ue-foundation/zs/put-overwrite-policy-response (diff)
downloadzen-347153218dd09e3806e5b27eb51f538768f27035.tar.xz
zen-347153218dd09e3806e5b27eb51f538768f27035.zip
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)
Diffstat (limited to 'src/zencore')
-rw-r--r--src/zencore/compactbinaryutil.cpp8
-rw-r--r--src/zencore/filesystem.cpp21
-rw-r--r--src/zencore/include/zencore/process.h1
3 files changed, 29 insertions, 1 deletions
diff --git a/src/zencore/compactbinaryutil.cpp b/src/zencore/compactbinaryutil.cpp
index c8cde21c3..074bdaffd 100644
--- a/src/zencore/compactbinaryutil.cpp
+++ b/src/zencore/compactbinaryutil.cpp
@@ -14,7 +14,13 @@ ValidateAndReadCompactBinaryObject(const SharedBuffer&& Payload, CbValidateError
{
if (OutError = ValidateCompactBinary(Payload.GetView(), CbValidateMode::Default); OutError == CbValidateError::None)
{
- return CbObject(std::move(Payload));
+ CbObject Object(std::move(Payload));
+ if (Object.GetView().GetSize() != Payload.GetSize())
+ {
+ OutError |= CbValidateError::OutOfBounds;
+ return {};
+ }
+ return Object;
}
}
return CbObject();
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)
diff --git a/src/zencore/include/zencore/process.h b/src/zencore/include/zencore/process.h
index 98d352db6..04b79a1e0 100644
--- a/src/zencore/include/zencore/process.h
+++ b/src/zencore/include/zencore/process.h
@@ -33,6 +33,7 @@ public:
ZENCORE_API bool Terminate(int ExitCode);
ZENCORE_API void Reset();
[[nodiscard]] inline int Pid() const { return m_Pid; }
+ [[nodiscard]] inline void* Handle() const { return m_ProcessHandle; }
private:
void* m_ProcessHandle = nullptr;