Skip to content

Commit d5babc7

Browse files
committed
fix: copy fallback uses legacy heuristic to validate copied content
Round-6 review fix: After Round-5 made is_install_complete() strict marker-only, the copy fallback path broke: bool copyOk = copy_xpkg_from_global(verdir); if (copyOk && is_install_complete(verdir)) { // ← always false mark_install_complete(...); // never reached return make_payload(); } clean_incomplete_install(verdir); // ← wipes the copy copy_xpkg_from_global() doesn't (and can't) write .mcpp_ok in the copied directory, so the marker-only check would always fail, and the just-copied package would be immediately wiped, returning "xpkg payload missing". Fix: validate the copied content via looks_complete_legacy() (the structural heuristic) before writing the marker. This is safe in this context because: 1. Step 2 of the resolve chain already cleaned any pre-existing residue using strict marker-only semantics — so anything at verdir now MUST be the result of our just-completed copy. 2. copy_xpkg_from_global() only returns true on a clean recursive copy (no partial copies reach this branch). 3. The heuristic validates that the source actually had content (rules out copying from an empty/broken global xlings dir). This restores the documented "copy_xpkg_from_global is the typical fast fallback" behavior that Round-5 unintentionally broke.
1 parent 161cb40 commit d5babc7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/pm/package_fetcher.cppm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,13 +703,20 @@ Fetcher::resolve_xpkg_path(std::string_view target,
703703
}
704704

705705
// 4. Copy fallback: xlings may have installed into its global data dir.
706+
// copy_xpkg_from_global() only returns true on a clean recursive
707+
// copy, but it doesn't write .mcpp_ok (the source predates this
708+
// feature). Validate content via the legacy layout heuristic, then
709+
// write the marker ourselves. We use looks_complete_legacy() here
710+
// rather than is_install_complete() (marker-only) because we just
711+
// copied this directory in: any "interrupted install" residue would
712+
// have been removed at step 2.
706713
bool copyOk = mcpp::fallback::copy_xpkg_from_global(verdir);
707-
if (copyOk && mcpp::fallback::is_install_complete(verdir)) {
714+
if (copyOk && mcpp::fallback::looks_complete_legacy(verdir)) {
708715
mcpp::fallback::mark_install_complete(verdir);
709716
mcpp::log::verbose("fetcher", "resolved via copy fallback");
710717
return make_payload();
711718
}
712-
// Copy failed or incomplete — clean partial copy.
719+
// Copy failed or produced an unrecognizable layout — clean partial copy.
713720
mcpp::fallback::clean_incomplete_install(verdir);
714721

715722
// 5. All paths exhausted — return the most informative error.

0 commit comments

Comments
 (0)