Skip to content

💫 Toolkit to help you get started with SDD or any other process!

fix: use missing_ok=True in extension ZIP cleanup (#3870)

Quratulain-bilale1617cebb1ec
diff --git a/src/specify_cli/extensions/_commands.py b/src/specify_cli/extensions/_commands.py
index f5125794c..11ab50385 100644
--- a/src/specify_cli/extensions/_commands.py
+++ b/src/specify_cli/extensions/_commands.py
@@ -1144,8 +1144,7 @@ def extension_add(
force=force,
)
finally:
- if archive_path.exists():
- archive_path.unlink()
+ archive_path.unlink(missing_ok=True)
console.print("\n[green]✓[/green] Extension installed successfully!")
console.print(f"\n[bold]{_escape_markup(str(manifest.name))}[/bold] (v{_escape_markup(str(manifest.version))})")
@@ -2410,11 +2409,10 @@ def extension_update(
# Archive cleanup is housekeeping: never replace an install
# error or roll back an already committed update because a
# scanner temporarily locks the download on Windows.
- if archive_path.exists():
- try:
- archive_path.unlink()
- except OSError as error:
- zip_cleanup_error = error
+ try:
+ archive_path.unlink(missing_ok=True)
+ except OSError as error:
+ zip_cleanup_error = error
# 10. Clean up backup on success. The update has committed at
# this point, so a locked backup file must not trigger rollback