From abe2c89fc0e4f41f00aca3510e9bb4902e52c9e7 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 4 Jul 2024 12:32:32 +0200 Subject: FileSystemManager::CreateFileHardlink: return error code on failure Instead of returning a plain boolean, return an expected with the same boolean value that in case of an error indicates the error code. In this way, an error-specific handling is possible by consumers. While there, also add proper quoting of the involved file names. --- .../serve_api/serve_service/source_tree.cpp | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/buildtool/serve_api/serve_service/source_tree.cpp') diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp index 74edaca8..480dfd34 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.cpp +++ b/src/buildtool/serve_api/serve_service/source_tree.cpp @@ -895,20 +895,21 @@ auto SourceTreeService::DistdirImportToGit( auto const& tmp_path = distdir_tmp_dir->GetPath(); // link the CAS blobs into the tmp dir auto const& cas = storage_.CAS(); - if (not std::all_of(content_list.begin(), - content_list.end(), - [&cas, tmp_path](auto const& kv) { - auto content_path = cas.BlobPath( - ArtifactDigest( - kv.second.first, 0, /*is_tree=*/false), - kv.second.second); - if (content_path) { - return FileSystemManager::CreateFileHardlink( - *content_path, // from: cas_path/content_id - tmp_path / kv.first); // to: tmp_path/name - } - return false; - })) { + if (not std::all_of( + content_list.begin(), + content_list.end(), + [&cas, tmp_path](auto const& kv) { + auto content_path = cas.BlobPath( + ArtifactDigest(kv.second.first, 0, /*is_tree=*/false), + kv.second.second); + if (content_path) { + return FileSystemManager::CreateFileHardlink( + *content_path, // from: cas_path/content_id + tmp_path / kv.first) // to: tmp_path/name + .has_value(); + } + return false; + })) { logger_->Emit(LogLevel::Error, "Failed to create links to CAS content {}", content_id); -- cgit v1.2.3