Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clean up target path upon storage in order to avoid merges of directories #25

Merged
merged 3 commits into from
Aug 16, 2024
Merged
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
11 changes: 9 additions & 2 deletions snakemake_storage_plugin_fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,15 @@ def retrieve_object(self):

def store_object(self):
# Ensure that the object is stored at the location specified by
# self.local_path().
self.query_path.parent.mkdir(exist_ok=True, parents=True)
# self.query_path.
if self.query_path.exists():
# Clean up the target path
if self.query_path.is_dir():
shutil.rmtree(self.query_path, ignore_errors=True)
else:
self.query_path.unlink(missing_ok=True)
else:
self.query_path.parent.mkdir(exist_ok=True, parents=True)
# We want to respect the permissions in the target folder, in particular the
# setgid bit. Hence, we use --no-p to avoid preserving of permissions from the
# source to the target.
Expand Down
Loading