From 82e222bf23dee04e6fb825037fbb4d86a9571ce0 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Tue, 21 Apr 2026 17:22:18 +0200 Subject: filesystem.h surface error codes (#998) - Improvement: File copy, scan, clone, and move operations now report the underlying OS error in failure messages --- src/zenserver/hub/hydration.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/zenserver/hub/hydration.cpp') 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& 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& 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)); + } } }); } -- cgit v1.2.3