Skip to content

Commit 46c0e22

Browse files
authored
Fix binary caching for 'upgrade'd packages (#1083)
1 parent 27c9da4 commit 46c0e22

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

include/vcpkg/commands.install.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ namespace vcpkg
9292
const Filesystem& fs,
9393
const InstalledPaths& installed);
9494

95+
void preclear_packages(const VcpkgPaths& paths, const ActionPlan& action_plan);
96+
9597
InstallSummary execute_plan(const VcpkgCmdArguments& args,
9698
const ActionPlan& action_plan,
9799
const KeepGoing keep_going,

src/vcpkg/commands.ci.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ namespace vcpkg::Commands::CI
514514
{
515515
msg::println_warning(msgCISkipInstallation, msg::list = Strings::join(", ", already_installed));
516516
}
517+
Install::preclear_packages(paths, action_plan);
517518
binary_cache.fetch(action_plan.install_actions);
518519
auto summary = Install::execute_plan(
519520
args, action_plan, KeepGoing::YES, paths, status_db, binary_cache, build_logs_recorder);

src/vcpkg/commands.install.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ namespace vcpkg
285285
const InstallDir install_dir =
286286
InstallDir::from_destination_root(paths.installed(), triplet, bcf.core_paragraph);
287287

288-
install_package_and_write_listfile(fs, paths.package_dir(bcf.core_paragraph.spec), install_dir);
288+
install_package_and_write_listfile(fs, package_dir, install_dir);
289289

290290
source_paragraph.state = InstallState::INSTALLED;
291291
write_update(fs, installed, source_paragraph);
@@ -514,6 +514,20 @@ namespace vcpkg
514514
TrackedPackageInstallGuard& operator=(const TrackedPackageInstallGuard&) = delete;
515515
};
516516

517+
void Install::preclear_packages(const VcpkgPaths& paths, const ActionPlan& action_plan)
518+
{
519+
auto& fs = paths.get_filesystem();
520+
for (auto&& action : action_plan.remove_actions)
521+
{
522+
fs.remove_all(paths.package_dir(action.spec), VCPKG_LINE_INFO);
523+
}
524+
525+
for (auto&& action : action_plan.install_actions)
526+
{
527+
fs.remove_all(action.package_dir.value_or_exit(VCPKG_LINE_INFO), VCPKG_LINE_INFO);
528+
}
529+
}
530+
517531
InstallSummary Install::execute_plan(const VcpkgCmdArguments& args,
518532
const ActionPlan& action_plan,
519533
const KeepGoing keep_going,
@@ -532,7 +546,6 @@ namespace vcpkg
532546
{
533547
TrackedPackageInstallGuard this_install(action_index++, action_count, results, action);
534548
Remove::remove_package(fs, paths.installed(), action.spec, status_db);
535-
fs.remove_all(paths.packages() / action.spec.dir(), VCPKG_LINE_INFO);
536549
results.back().build_result.emplace(BuildResult::REMOVED);
537550
}
538551

@@ -1270,6 +1283,7 @@ namespace vcpkg
12701283
paths.flush_lockfile();
12711284

12721285
track_install_plan(action_plan);
1286+
Install::preclear_packages(paths, action_plan);
12731287

12741288
auto binary_cache = only_downloads ? BinaryCache(paths.get_filesystem())
12751289
: BinaryCache::make(args, paths, stdout_sink).value_or_exit(VCPKG_LINE_INFO);

src/vcpkg/commands.remove.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ namespace vcpkg::Remove
288288
{
289289
for (auto&& action : plan.not_installed)
290290
{
291-
fs.remove_all(paths.packages() / action.spec.dir(), VCPKG_LINE_INFO);
291+
fs.remove_all(paths.package_dir(action.spec), VCPKG_LINE_INFO);
292292
}
293293
}
294294

@@ -302,7 +302,7 @@ namespace vcpkg::Remove
302302
remove_package(fs, paths.installed(), action.spec, status_db);
303303
if (purge == Purge::YES)
304304
{
305-
fs.remove_all(paths.packages() / action.spec.dir(), VCPKG_LINE_INFO);
305+
fs.remove_all(paths.package_dir(action.spec), VCPKG_LINE_INFO);
306306
}
307307
}
308308

src/vcpkg/commands.set-installed.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ namespace vcpkg::Commands::SetInstalled
131131
paths.flush_lockfile();
132132

133133
track_install_plan(action_plan);
134+
Install::preclear_packages(paths, action_plan);
134135

135136
auto binary_cache = only_downloads ? BinaryCache(paths.get_filesystem())
136137
: BinaryCache::make(args, paths, stdout_sink).value_or_exit(VCPKG_LINE_INFO);

src/vcpkg/postbuildlint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ namespace vcpkg
354354
const VcpkgPaths& paths,
355355
MessageSink& msg_sink)
356356
{
357-
const auto packages_dir = paths.packages() / spec.dir();
357+
const auto packages_dir = paths.package_dir(spec);
358358
const auto copyright_file = packages_dir / "share" / spec.name() / "copyright";
359359

360360
switch (fs.status(copyright_file, IgnoreErrors{}))

0 commit comments

Comments
 (0)