diff options
Diffstat (limited to 'src/zen')
| -rw-r--r-- | src/zen/cmds/admin_cmd.cpp | 13 | ||||
| -rw-r--r-- | src/zen/cmds/bench_cmd.cpp | 2 | ||||
| -rw-r--r-- | src/zen/cmds/cache_cmd.cpp | 2 | ||||
| -rw-r--r-- | src/zen/cmds/dedup_cmd.cpp | 13 | ||||
| -rw-r--r-- | src/zen/cmds/projectstore_cmd.cpp | 2 | ||||
| -rw-r--r-- | src/zen/cmds/service_cmd.cpp | 4 |
6 files changed, 25 insertions, 11 deletions
diff --git a/src/zen/cmds/admin_cmd.cpp b/src/zen/cmds/admin_cmd.cpp index 12ffd49aa..2580517fa 100644 --- a/src/zen/cmds/admin_cmd.cpp +++ b/src/zen/cmds/admin_cmd.cpp @@ -489,9 +489,10 @@ LoggingCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { throw std::runtime_error(fmt::format("Failed to retrieve {} log path", SourceName)); } - if (!CopyFile(SourcePath, TargetPath, {})) + if (std::error_code Ec = CopyFile(SourcePath, TargetPath, {}); Ec) { - throw std::runtime_error( + throw std::system_error( + Ec, fmt::format("Failed to copy {} log file {} to output file '{}'", SourceName, SourcePath, TargetPath)); } }; @@ -585,7 +586,10 @@ Copy(const std::filesystem::path& Source, const std::filesystem::path& Target) CreateDirectories(Target.parent_path()); CopyFileOptions Options; - CopyFile(Source, Target, Options); + if (std::error_code Ec = CopyFile(Source, Target, Options); Ec) + { + throw std::system_error(Ec, fmt::format("Failed to copy '{}' to '{}'", Source, Target)); + } } static bool @@ -599,7 +603,8 @@ TryCopy(const std::filesystem::path& Source, const std::filesystem::path& Target CreateDirectories(Target.parent_path()); CopyFileOptions Options; - return CopyFile(Source, Target, Options); + std::error_code Ec = CopyFile(Source, Target, Options); + return !Ec; } void diff --git a/src/zen/cmds/bench_cmd.cpp b/src/zen/cmds/bench_cmd.cpp index b1639105a..c935179e2 100644 --- a/src/zen/cmds/bench_cmd.cpp +++ b/src/zen/cmds/bench_cmd.cpp @@ -1661,7 +1661,7 @@ BenchDiskSubCmd::RunClone(const std::filesystem::path& Dir) try { std::filesystem::path DstPath = Dir / fmt::format("bench_clone_{}.tmp", FileIndex); - if (TryCloneFile(SrcPath, DstPath)) + if (std::error_code CloneEc = TryCloneFile(SrcPath, DstPath); !CloneEc) { CloneCount.fetch_add(1, std::memory_order_relaxed); } diff --git a/src/zen/cmds/cache_cmd.cpp b/src/zen/cmds/cache_cmd.cpp index c03284462..f93a5318c 100644 --- a/src/zen/cmds/cache_cmd.cpp +++ b/src/zen/cmds/cache_cmd.cpp @@ -759,7 +759,7 @@ CacheGetSubCmd::Run(const ZenCliOptions& /*GlobalOptions*/) } else { - if (MoveToFile(m_OutputPath, ChunkData)) + if (std::error_code MoveEc = MoveToFile(m_OutputPath, ChunkData); MoveEc) { // The file was renamed into place; clearing DeleteOnClose prevents // the move'd-out file at m_OutputPath from being deleted when the diff --git a/src/zen/cmds/dedup_cmd.cpp b/src/zen/cmds/dedup_cmd.cpp index 9ef50a97d..18ad56aec 100644 --- a/src/zen/cmds/dedup_cmd.cpp +++ b/src/zen/cmds/dedup_cmd.cpp @@ -240,7 +240,12 @@ DedupCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { zen::BLAKE3Stream b3s; - zen::ScanFile(Entry.path(), 64 * 1024, [&](const void* Data, size_t Size) { b3s.Append(Data, Size); }); + if (std::error_code ScanEc = + zen::ScanFile(Entry.path(), 64 * 1024, [&](const void* Data, size_t Size) { b3s.Append(Data, Size); }); + ScanEc) + { + throw std::system_error(ScanEc, fmt::format("Failed to scan file '{}'", Entry.path())); + } Hash = b3s.GetHash(); } @@ -279,7 +284,11 @@ DedupCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) Options.EnableClone = true; Options.MustClone = true; - zen::CopyFile(Dupe->path(), Entry.path(), Options); + if (std::error_code Ec = zen::CopyFile(Dupe->path(), Entry.path(), Options); Ec) + { + ZEN_ERROR("Failed to clone '{}' to '{}': {}", Dupe->path(), Entry.path(), Ec.message()); + continue; + } DupeBytes += Entry.file_size(); } diff --git a/src/zen/cmds/projectstore_cmd.cpp b/src/zen/cmds/projectstore_cmd.cpp index d9ce1cfa7..c6a3434f8 100644 --- a/src/zen/cmds/projectstore_cmd.cpp +++ b/src/zen/cmds/projectstore_cmd.cpp @@ -2191,7 +2191,7 @@ OplogMirrorCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** arg IoBuffer ChunkData = m_Decompress ? TryDecompress(ChunkResponse.ResponsePayload) : ChunkResponse.ResponsePayload; - if (!MoveToFile(TargetPath, ChunkData)) + if (std::error_code MoveEc = MoveToFile(TargetPath, ChunkData); MoveEc) { WriteFile(TargetPath, ChunkData); } diff --git a/src/zen/cmds/service_cmd.cpp b/src/zen/cmds/service_cmd.cpp index 5e284cbdf..c43c4e614 100644 --- a/src/zen/cmds/service_cmd.cpp +++ b/src/zen/cmds/service_cmd.cpp @@ -500,9 +500,9 @@ ServiceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { std::filesystem::path Destination = m_InstallPath / File.filename(); - if (!CopyFile(File, Destination, {.EnableClone = false})) + if (std::error_code CopyEc = CopyFile(File, Destination, {.EnableClone = false}); CopyEc) { - throw std::runtime_error(fmt::format("Failed to copy '{}' to '{}'", File, Destination)); + throw std::system_error(CopyEc, fmt::format("Failed to copy '{}' to '{}'", File, Destination)); } ZEN_INFO("Copied '{}' to '{}'", File, Destination); |