Skip to content

Commit 505d868

Browse files
fix: be more explicit about rsync args and ensure that symlinks are copied (avoiding that they point to non-existing files); to not copy permissions and ownership (thanks @landerini) (#38)
fixes #34 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added local storage footprint reporting to show size for files and directories (recursively) and zero for on-demand eligible items. * **Bug Fixes** * Improved file transfer behavior with more explicit transfer options for reliable recursive copying, timestamps, symlink handling, and permissions/ownership preservation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 55fe634 commit 505d868

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

snakemake_storage_plugin_fs/__init__.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ def size(self) -> int:
197197
# return the size in bytes
198198
return self._stat().st_size
199199

200+
def local_footprint(self) -> int:
201+
if self.is_ondemand_eligible:
202+
# If the object is not downloaded, we don't have to count it.
203+
return 0
204+
if self.query_path.is_dir():
205+
# If the object is a directory, we have to count all files in it.
206+
return sum(
207+
f.stat().st_size for f in self.query_path.rglob("*") if f.is_file()
208+
)
209+
return self.size()
210+
200211
def retrieve_object(self):
201212
# Ensure that the object is accessible locally under self.local_path()
202213
if self.is_ondemand_eligible:
@@ -212,7 +223,13 @@ def retrieve_object(self):
212223
)
213224
else:
214225
cmd = sysrsync.get_rsync_command(
215-
str(self.query_path), str(self.local_path()), options=["-av"]
226+
str(self.query_path),
227+
str(self.local_path()),
228+
options=[
229+
"--recursive",
230+
"--times",
231+
"--copy-links",
232+
],
216233
)
217234
self._run_cmd(cmd)
218235

@@ -235,7 +252,11 @@ def store_object(self):
235252
str(self.query_path),
236253
# ensure that permissions and ownership are inherited from destination,
237254
# e.g. setgid.
238-
options=["-av", "--no-o", "--no-g", "--no-p"],
255+
options=[
256+
"--recursive",
257+
"--times",
258+
"--copy-links",
259+
],
239260
)
240261
self._run_cmd(cmd)
241262

0 commit comments

Comments
 (0)