From 114ad93775cdf2ae26cec74973f7832583495dcf Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 16 Aug 2024 14:53:15 +0200 Subject: [PATCH 1/3] fix: clean up target path upon storage in order to avoid merges of directories. --- snakemake_storage_plugin_fs/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snakemake_storage_plugin_fs/__init__.py b/snakemake_storage_plugin_fs/__init__.py index 45a8a7e..7434a89 100644 --- a/snakemake_storage_plugin_fs/__init__.py +++ b/snakemake_storage_plugin_fs/__init__.py @@ -208,6 +208,11 @@ 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) + # Clean up the target path + if self.local_path().is_dir(): + shutil.rmtree(self.query_path, ignore_errors=True) + else: + self.query_path.unlink(missing_ok=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. From 84e1133a1b16d321e3248a1f932fb30e43d0a32c Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 16 Aug 2024 14:59:50 +0200 Subject: [PATCH 2/3] fix --- snakemake_storage_plugin_fs/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/snakemake_storage_plugin_fs/__init__.py b/snakemake_storage_plugin_fs/__init__.py index 7434a89..383747d 100644 --- a/snakemake_storage_plugin_fs/__init__.py +++ b/snakemake_storage_plugin_fs/__init__.py @@ -209,10 +209,11 @@ def store_object(self): # self.local_path(). self.query_path.parent.mkdir(exist_ok=True, parents=True) # Clean up the target path - if self.local_path().is_dir(): - shutil.rmtree(self.query_path, ignore_errors=True) - else: - self.query_path.unlink(missing_ok=True) + if self.query_path.exists(): + if self.query_path.is_dir(): + shutil.rmtree(self.query_path, ignore_errors=True) + else: + self.query_path.unlink(missing_ok=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. From cd09e0851bf013a5f5b0beb61e29fc1111726ba1 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Fri, 16 Aug 2024 15:01:08 +0200 Subject: [PATCH 3/3] fix --- snakemake_storage_plugin_fs/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snakemake_storage_plugin_fs/__init__.py b/snakemake_storage_plugin_fs/__init__.py index 383747d..00cdd60 100644 --- a/snakemake_storage_plugin_fs/__init__.py +++ b/snakemake_storage_plugin_fs/__init__.py @@ -206,14 +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) - # Clean up the target path + # 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.