Skip to content

Commit dfde23a

Browse files
committed
fix: check kept_artifact in run_vendor_gc to prevent orphan sweep
When run_vendor_gc receives a drift-skip keep (kept_artifact: true) from dispatch_revert_one, it must keep the ledger entry instead of pruning it. Otherwise the trailing orphan sweep deletes artifacts the backend deliberately retained, recreating residual #131 via scan --prune. This fix adds the kept_artifact check to both section (a) manifest-dropped and section (b) lockfile-unused paths, matching the contract already wired into reconcile_dropped and run_revert.
1 parent 7a2013f commit dfde23a

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

  • crates/socket-patch-cli/src/commands

crates/socket-patch-cli/src/commands/vendor.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,10 +1568,13 @@ pub(crate) async fn run_vendor_gc(
15681568
continue;
15691569
}
15701570
let entry = state.entries.get(&purl).cloned().expect("listed above");
1571-
if dispatch_revert_one(&entry, &common.cwd, false)
1572-
.await
1573-
.success
1574-
{
1571+
let outcome = dispatch_revert_one(&entry, &common.cwd, false).await;
1572+
if outcome.success {
1573+
if outcome.kept_artifact {
1574+
// Drift-skip keep: backend kept the uuid dir, so the ledger
1575+
// entry must survive too (same contract as reconcile_dropped).
1576+
continue;
1577+
}
15751578
state.entries.remove(&purl);
15761579
out.dropped_reverted.push(purl);
15771580
} else {
@@ -1601,13 +1604,16 @@ pub(crate) async fn run_vendor_gc(
16011604
out.unused_reverted.push(purl);
16021605
continue;
16031606
}
1604-
if !dispatch_revert_one(&entry, &common.cwd, false)
1605-
.await
1606-
.success
1607-
{
1607+
let outcome = dispatch_revert_one(&entry, &common.cwd, false).await;
1608+
if !outcome.success {
16081609
out.failed.push(purl);
16091610
continue;
16101611
}
1612+
if outcome.kept_artifact {
1613+
// Drift-skip keep: backend kept the uuid dir, so the ledger
1614+
// entry must survive too (same contract as reconcile_dropped).
1615+
continue;
1616+
}
16111617
state.entries.remove(&purl);
16121618
if let Some(m) = manifest.as_mut() {
16131619
let base = strip_purl_qualifiers(&entry.base_purl).to_string();

0 commit comments

Comments
 (0)