diff options
| author | Dan Engelbrecht <[email protected]> | 2026-04-21 17:22:18 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-21 17:22:18 +0200 |
| commit | 82e222bf23dee04e6fb825037fbb4d86a9571ce0 (patch) | |
| tree | 007b805500a5e23167ae8acc977efc3a6298d826 /src/zenserver | |
| parent | improved s3 hydration (#997) (diff) | |
| download | archived-zen-82e222bf23dee04e6fb825037fbb4d86a9571ce0.tar.xz archived-zen-82e222bf23dee04e6fb825037fbb4d86a9571ce0.zip | |
filesystem.h surface error codes (#998)
- Improvement: File copy, scan, clone, and move operations now report the underlying OS error in failure messages
Diffstat (limited to 'src/zenserver')
| -rw-r--r-- | src/zenserver/hub/hydration.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/zenserver/hub/hydration.cpp b/src/zenserver/hub/hydration.cpp index 4b2294b49..259171b49 100644 --- a/src/zenserver/hub/hydration.cpp +++ b/src/zenserver/hub/hydration.cpp @@ -239,7 +239,11 @@ namespace hydration_impl { [this, Hash = IoHash(Hash), SourcePath = std::filesystem::path(SourcePath)](std::atomic<bool>& AbortFlag) { if (!AbortFlag.load()) { - CopyFile(SourcePath, m_CASPath / fmt::format("{}", Hash), CopyFileOptions{.EnableClone = true}); + std::filesystem::path DestPath = m_CASPath / fmt::format("{}", Hash); + if (std::error_code Ec = CopyFile(SourcePath, DestPath, CopyFileOptions{.EnableClone = true}); Ec) + { + throw std::system_error(Ec, fmt::format("Failed to copy '{}' to '{}'", SourcePath, DestPath)); + } } }); } @@ -256,7 +260,11 @@ namespace hydration_impl { [this, Hash = IoHash(Hash), DestinationPath = std::filesystem::path(DestinationPath)](std::atomic<bool>& AbortFlag) { if (!AbortFlag.load()) { - CopyFile(m_CASPath / fmt::format("{}", Hash), DestinationPath, CopyFileOptions{.EnableClone = true}); + std::filesystem::path SourcePath = m_CASPath / fmt::format("{}", Hash); + if (std::error_code Ec = CopyFile(SourcePath, DestinationPath, CopyFileOptions{.EnableClone = true}); Ec) + { + throw std::system_error(Ec, fmt::format("Failed to copy '{}' to '{}'", SourcePath, DestinationPath)); + } } }); } |