Skip to content

Commit b621567

Browse files
committed
fix: use consistent resolved root for stale-file cleanup paths
1 parent 43f4d8d commit b621567

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,17 +2319,17 @@ def integration_upgrade(
23192319
raise typer.Exit(1)
23202320

23212321
# Phase 2: Remove stale files from old manifest that are not in the new one
2322-
resolved_project_root = project_root.resolve()
2322+
root = project_root.resolve()
23232323
old_files = set(old_manifest.files.keys())
23242324
new_files = set(new_manifest.files.keys())
23252325
stale_files = old_files - new_files
23262326
stale_removed = 0
23272327
for rel in stale_files:
2328-
path = project_root / rel
2328+
path = root / rel
23292329
# Validate containment to prevent path traversal from tampered manifests
23302330
try:
23312331
normed = Path(os.path.normpath(path))
2332-
normed.relative_to(resolved_project_root)
2332+
normed.relative_to(root)
23332333
except (ValueError, OSError):
23342334
continue
23352335
if path.is_symlink() or path.is_file():
@@ -2338,7 +2338,7 @@ def integration_upgrade(
23382338
stale_removed += 1
23392339
# Clean up empty parent directories up to project root
23402340
parent = path.parent
2341-
while parent != project_root:
2341+
while parent != root:
23422342
try:
23432343
parent.rmdir()
23442344
except OSError:

0 commit comments

Comments
 (0)