Skip to content

Commit

Permalink
Fix binary caching for 'upgrade'd packages (#1083)
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal authored May 31, 2023
1 parent 27c9da4 commit 46c0e22
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/vcpkg/commands.install.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ namespace vcpkg
const Filesystem& fs,
const InstalledPaths& installed);

void preclear_packages(const VcpkgPaths& paths, const ActionPlan& action_plan);

InstallSummary execute_plan(const VcpkgCmdArguments& args,
const ActionPlan& action_plan,
const KeepGoing keep_going,
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ namespace vcpkg::Commands::CI
{
msg::println_warning(msgCISkipInstallation, msg::list = Strings::join(", ", already_installed));
}
Install::preclear_packages(paths, action_plan);
binary_cache.fetch(action_plan.install_actions);
auto summary = Install::execute_plan(
args, action_plan, KeepGoing::YES, paths, status_db, binary_cache, build_logs_recorder);
Expand Down
18 changes: 16 additions & 2 deletions src/vcpkg/commands.install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ namespace vcpkg
const InstallDir install_dir =
InstallDir::from_destination_root(paths.installed(), triplet, bcf.core_paragraph);

install_package_and_write_listfile(fs, paths.package_dir(bcf.core_paragraph.spec), install_dir);
install_package_and_write_listfile(fs, package_dir, install_dir);

source_paragraph.state = InstallState::INSTALLED;
write_update(fs, installed, source_paragraph);
Expand Down Expand Up @@ -514,6 +514,20 @@ namespace vcpkg
TrackedPackageInstallGuard& operator=(const TrackedPackageInstallGuard&) = delete;
};

void Install::preclear_packages(const VcpkgPaths& paths, const ActionPlan& action_plan)
{
auto& fs = paths.get_filesystem();
for (auto&& action : action_plan.remove_actions)
{
fs.remove_all(paths.package_dir(action.spec), VCPKG_LINE_INFO);
}

for (auto&& action : action_plan.install_actions)
{
fs.remove_all(action.package_dir.value_or_exit(VCPKG_LINE_INFO), VCPKG_LINE_INFO);
}
}

InstallSummary Install::execute_plan(const VcpkgCmdArguments& args,
const ActionPlan& action_plan,
const KeepGoing keep_going,
Expand All @@ -532,7 +546,6 @@ namespace vcpkg
{
TrackedPackageInstallGuard this_install(action_index++, action_count, results, action);
Remove::remove_package(fs, paths.installed(), action.spec, status_db);
fs.remove_all(paths.packages() / action.spec.dir(), VCPKG_LINE_INFO);
results.back().build_result.emplace(BuildResult::REMOVED);
}

Expand Down Expand Up @@ -1270,6 +1283,7 @@ namespace vcpkg
paths.flush_lockfile();

track_install_plan(action_plan);
Install::preclear_packages(paths, action_plan);

auto binary_cache = only_downloads ? BinaryCache(paths.get_filesystem())
: BinaryCache::make(args, paths, stdout_sink).value_or_exit(VCPKG_LINE_INFO);
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.remove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ namespace vcpkg::Remove
{
for (auto&& action : plan.not_installed)
{
fs.remove_all(paths.packages() / action.spec.dir(), VCPKG_LINE_INFO);
fs.remove_all(paths.package_dir(action.spec), VCPKG_LINE_INFO);
}
}

Expand All @@ -302,7 +302,7 @@ namespace vcpkg::Remove
remove_package(fs, paths.installed(), action.spec, status_db);
if (purge == Purge::YES)
{
fs.remove_all(paths.packages() / action.spec.dir(), VCPKG_LINE_INFO);
fs.remove_all(paths.package_dir(action.spec), VCPKG_LINE_INFO);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/commands.set-installed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ namespace vcpkg::Commands::SetInstalled
paths.flush_lockfile();

track_install_plan(action_plan);
Install::preclear_packages(paths, action_plan);

auto binary_cache = only_downloads ? BinaryCache(paths.get_filesystem())
: BinaryCache::make(args, paths, stdout_sink).value_or_exit(VCPKG_LINE_INFO);
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ namespace vcpkg
const VcpkgPaths& paths,
MessageSink& msg_sink)
{
const auto packages_dir = paths.packages() / spec.dir();
const auto packages_dir = paths.package_dir(spec);
const auto copyright_file = packages_dir / "share" / spec.name() / "copyright";

switch (fs.status(copyright_file, IgnoreErrors{}))
Expand Down

0 comments on commit 46c0e22

Please sign in to comment.