mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 10:21:07 +08:00
[vcpkg] fail archived port install when decompression fails (#7086)
* [vcpkg] fail port install when decompression fails * [vcpkg] clang-format
This commit is contained in:
parent
bd72762f69
commit
8e747d659c
@ -594,7 +594,7 @@ namespace vcpkg::Build
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
static void decompress_archive(const VcpkgPaths& paths, const PackageSpec& spec, const fs::path& archive_path)
|
||||
static int decompress_archive(const VcpkgPaths& paths, const PackageSpec& spec, const fs::path& archive_path)
|
||||
{
|
||||
auto& fs = paths.get_filesystem();
|
||||
|
||||
@ -608,12 +608,13 @@ namespace vcpkg::Build
|
||||
#if defined(_WIN32)
|
||||
auto&& seven_zip_exe = paths.get_tool_exe(Tools::SEVEN_ZIP);
|
||||
|
||||
System::cmd_execute_clean(Strings::format(
|
||||
int result = System::cmd_execute_clean(Strings::format(
|
||||
R"("%s" x "%s" -o"%s" -y >nul)", seven_zip_exe.u8string(), archive_path.u8string(), pkg_path.u8string()));
|
||||
#else
|
||||
System::cmd_execute_clean(
|
||||
int result = System::cmd_execute_clean(
|
||||
Strings::format(R"(unzip -qq "%s" "-d%s")", archive_path.u8string(), pkg_path.u8string()));
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
// Compress the source directory into the destination file.
|
||||
@ -699,11 +700,16 @@ namespace vcpkg::Build
|
||||
{
|
||||
System::print2("Using cached binary package: ", archive_path.u8string(), "\n");
|
||||
|
||||
decompress_archive(paths, spec, archive_path);
|
||||
auto archive_result = decompress_archive(paths, spec, archive_path);
|
||||
|
||||
if (archive_result != 0)
|
||||
{
|
||||
System::print2("Failed to decompress archive package\n");
|
||||
return BuildResult::BUILD_FAILED;
|
||||
}
|
||||
|
||||
auto maybe_bcf = Paragraphs::try_load_cached_package(paths, spec);
|
||||
std::unique_ptr<BinaryControlFile> bcf =
|
||||
std::make_unique<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));
|
||||
auto bcf = std::make_unique<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));
|
||||
return {BuildResult::SUCCEEDED, std::move(bcf)};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user