fix: only delete manifest when full tracked set was processed

When remove_tracked_files is called with an explicit files dict (subset),
skip manifest deletion to avoid losing tracking of entries not in the
subset. Manifest cleanup only runs when the full set is read from the
manifest itself (files=None).
This commit is contained in:
Manfred Riem
2026-03-23 15:15:28 -05:00
parent 38ae759568
commit b59b82813c

View File

@@ -695,11 +695,12 @@ def remove_tracked_files(
abs_path.unlink() abs_path.unlink()
removed.append(rel_path) removed.append(rel_path)
# Clean up the install manifest only when no tracked files remain # Clean up the install manifest only when the full tracked set was
# on disk. Files already deleted by the user count as gone, not # processed (i.e. read from the manifest itself). When an explicit
# as "remaining" — only files that still exist and were skipped # ``files`` dict is provided the caller may be passing a subset
# (e.g. modified without --force) prevent manifest cleanup. # (e.g. only agent_files), so deleting the manifest could lose
if manifest_file.is_file(): # tracking of entries not in the subset.
if files is None and manifest_file.is_file():
still_on_disk = sum( still_on_disk = sum(
1 for rel_path in entries 1 for rel_path in entries
if (project_path / rel_path).is_file() if (project_path / rel_path).is_file()