[vcpkg] Handle failure to store archive
MODIFY
include/vcpkg/base/files.h
include/vcpkg/base/files.h
@@ -36,6 +36,7 @@ namespace vcpkg::Files
virtual void write_lines(const fs::path& file_path, const std::vector<std::string>& lines) = 0;
virtual void write_contents(const fs::path& file_path, const std::string& data, std::error_code& ec) = 0;
virtual void rename(const fs::path& oldpath, const fs::path& newpath) = 0;
+ virtual void rename(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) = 0;
virtual bool remove(const fs::path& path) = 0;
virtual bool remove(const fs::path& path, std::error_code& ec) = 0;
virtual std::uintmax_t remove_all(const fs::path& path, std::error_code& ec) = 0;

MODIFY
src/vcpkg/base/files.cpp
src/vcpkg/base/files.cpp
@@ -108,6 +108,10 @@ namespace vcpkg::Files
output.close();
}
+ virtual void rename(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) override
+ {
+ fs::stdfs::rename(oldpath, newpath, ec);
+ }
virtual void rename(const fs::path& oldpath, const fs::path& newpath) override
{
fs::stdfs::rename(oldpath, newpath);

MODIFY
src/vcpkg/build.cpp
src/vcpkg/build.cpp
@@ -618,8 +618,11 @@ namespace vcpkg::Build
compress_archive(paths, spec, tmp_archive_path);
fs.create_directories(archive_path.parent_path(), ec);
- fs.rename(tmp_archive_path, archive_path);
-
+ fs.rename(tmp_archive_path, archive_path, ec);
+ if (ec)
+ System::println(
+ System::Color::warning, "Failed to store binary cache: %s", archive_path.u8string());
+ else
System::println("Stored binary cache: %s", archive_path.u8string());
}
else if (result.code == BuildResult::BUILD_FAILED || result.code == BuildResult::POST_BUILD_CHECKS_FAILED)

[vcpkg] Handle failure to store archive