From 8e747d659c40775ce2a5a2e5d0230e4fd659ef57 Mon Sep 17 00:00:00 2001 From: Phil Christensen Date: Sun, 30 Jun 2019 00:15:08 -0700 Subject: [PATCH] [vcpkg] fail archived port install when decompression fails (#7086) * [vcpkg] fail port install when decompression fails * [vcpkg] clang-format --- toolsrc/src/vcpkg/build.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index f826a48652..9694bce4c1 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -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 bcf = - std::make_unique(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO)); + auto bcf = std::make_unique(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO)); return {BuildResult::SUCCEEDED, std::move(bcf)}; }