Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/specify_cli/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ def atomic_write_json(target_file: Path, payload: dict[str, Any]) -> None:

os.replace(temp_path, target_file)
except Exception:
if temp_path and temp_path.exists():
temp_path.unlink()
if temp_path:
try:
temp_path.unlink(missing_ok=True)
except OSError:
pass
raise

try:
Expand Down
6 changes: 4 additions & 2 deletions src/specify_cli/integrations/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,10 @@ def save(self) -> Path:
_ensure_safe_manifest_destination(self.project_root, path)
os.replace(temp_path, path)
finally:
if temp_path.exists():
temp_path.unlink()
try:
temp_path.unlink(missing_ok=True)
except OSError:
pass
return path

@classmethod
Expand Down
6 changes: 4 additions & 2 deletions src/specify_cli/shared_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ def _write_shared_bytes(
_ensure_safe_shared_destination(project_path, dest)
os.replace(temp_path, dest)
finally:
if temp_path.exists():
temp_path.unlink()
try:
temp_path.unlink(missing_ok=True)
except OSError:
pass


_BASH_FORMAT_COMMAND_RE = re.compile(
Expand Down