Skip to content

Commit

Permalink
[vcpkg] fail archived port install when decompression fails (#7086)
Browse files Browse the repository at this point in the history
* [vcpkg] fail port install when decompression fails

* [vcpkg] clang-format
  • Loading branch information
Rastaban authored Jun 30, 2019
1 parent bd72762 commit 8e747d6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions toolsrc/src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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.
Expand Down Expand Up @@ -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)};
}

Expand Down

0 comments on commit 8e747d6

Please sign in to comment.