Inaccessible lock files now imply temporary directories can't be removed

Fix #7500

Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
Bruno Oliveira
2020-07-15 09:25:17 -03:00
committed by GitHub
parent 41c40efe80
commit e7c42ae62b
3 changed files with 20 additions and 5 deletions

View File

@@ -286,12 +286,17 @@ def maybe_delete_a_numbered_dir(path: Path) -> None:
def ensure_deletable(path: Path, consider_lock_dead_if_created_before: float) -> bool:
"""checks if a lock exists and breaks it if its considered dead"""
"""checks if `path` is deletable based on whether the lock file is expired"""
if path.is_symlink():
return False
lock = get_lock_path(path)
if not lock.exists():
return True
try:
if not lock.is_file():
return True
except OSError:
# we might not have access to the lock file at all, in this case assume
# we don't have access to the entire directory (#7491).
return False
try:
lock_time = lock.stat().st_mtime
except Exception: