diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-07-04 12:32:32 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-07-05 15:16:23 +0200 |
commit | abe2c89fc0e4f41f00aca3510e9bb4902e52c9e7 (patch) | |
tree | 82105fa2275f1d2f403215d6c268b8b419cebeb0 /src/buildtool/serve_api/serve_service/source_tree.cpp | |
parent | b1ce7ce328e322cafa2401af77a9334c61b72034 (diff) | |
download | justbuild-abe2c89fc0e4f41f00aca3510e9bb4902e52c9e7.tar.gz |
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.
Diffstat (limited to 'src/buildtool/serve_api/serve_service/source_tree.cpp')
-rw-r--r-- | src/buildtool/serve_api/serve_service/source_tree.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
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); |