Skip to content

Commit cd09b62

Browse files
committed
Preserve dangling symlinks during export recovery
1 parent 2aa076b commit cd09b62

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/openstatspec/spss/sav.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ def _path_reference_text(path: Path, *, role: str) -> str:
305305
)
306306

307307

308+
def _path_entry_exists(path: Path) -> bool:
309+
"""Report directory entries without following a possibly dangling symlink."""
310+
return path.exists() or path.is_symlink()
311+
312+
308313
def _reserve_export_backup(destination: Path) -> Path:
309314
descriptor, name = mkstemp(
310315
dir=destination.parent, prefix=f".{destination.name}.",
@@ -579,7 +584,7 @@ def export_sav_dataset(
579584
staged_destination, frame, dataset, variables,
580585
legacy_locale=legacy_locale,
581586
)
582-
had_previous = destination_path.exists()
587+
had_previous = _path_entry_exists(destination_path)
583588
backup = _reserve_export_backup(destination_path)
584589
if not had_previous:
585590
backup.unlink()

0 commit comments

Comments
 (0)