Skip to content

Commit

Permalink
Fix existing cache on copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Koncopd committed Dec 3, 2024
1 parent 3487e24 commit 1d5e1be
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lamindb/_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,17 @@ def copy_or_move_to_cache(
return None
# non-local storage_path further
if local_path != cache_path:
cache_path.parent.mkdir(parents=True, exist_ok=True)
if cache_dir in local_path.parents:
if cache_path.exists():
logger.warning(
f"The cache path {cache_path.as_posix()} already exists, replacing it."
)
if cache_path.is_dir():
shutil.rmtree(cache_path)
else:
cache_path.unlink()
else:
cache_path.parent.mkdir(parents=True, exist_ok=True)
if cache_dir in local_path.parents:
local_path.replace(cache_path)
else:
if is_dir:
Expand Down

0 comments on commit 1d5e1be

Please sign in to comment.