diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/buildtool/main/install_cas.cpp | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b2f730..17df375a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ A feature release on top of `1.1.0`, backwards compatible. the local build root. - `just install-cas` now correctly handles `--raw-tree` also for remote-execution endpoints. +- `just install-cas` now, like `just install`, removes an existing + destination file before installing instead of overwriting. ## Release `1.1.0` (2023-05-19) diff --git a/src/buildtool/main/install_cas.cpp b/src/buildtool/main/install_cas.cpp index 1c0290df..99867de8 100644 --- a/src/buildtool/main/install_cas.cpp +++ b/src/buildtool/main/install_cas.cpp @@ -180,8 +180,21 @@ auto FetchAndInstallArtifacts( output_path /= object_info.digest.hash(); } - if (not FileSystemManager::CreateDirectory(output_path.parent_path()) or - not api->RetrieveToPaths( + if (not FileSystemManager::CreateDirectory(output_path.parent_path())) { + Logger::Log(LogLevel::Error, + "failed to create parent directory {}.", + output_path.parent_path().string()); + return false; + } + if (FileSystemManager::Exists(output_path)) { + if (not FileSystemManager::RemoveFile(output_path)) { + Logger::Log(LogLevel::Error, + "Failed to remote target location {}.", + output_path.string()); + return false; + } + } + if (not api->RetrieveToPaths( {object_info}, {output_path}, alternative_api)) { Logger::Log(LogLevel::Error, "failed to retrieve artifact."); return false; |