From a4665f62699fec45d8b6d6ea7ed95645fe9dafdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=B6nch?= Date: Fri, 5 Jul 2024 11:41:49 +0200 Subject: [PATCH] fix: strip complete base directory from tarfile paths Strip the complete input base directory from the paths the are used in the study-visit tar-files. This commit fixes issue --- bin/make_studyvisit_archive | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/make_studyvisit_archive b/bin/make_studyvisit_archive index fe52b53..d7bf875 100755 --- a/bin/make_studyvisit_archive +++ b/bin/make_studyvisit_archive @@ -85,6 +85,7 @@ def write_archive( # adjust properties to make archive builds reproducible tinfo = normalize_tarinfo( tinfo, + input_base_dir, archive_content_base_dir, # go with the reported timestamp from DICOM or with default content[p] or default_timestamp, @@ -94,9 +95,10 @@ def write_archive( tar.addfile(tinfo, fp) -def normalize_tarinfo(tinfo, archive_path, timestamp): +def normalize_tarinfo(tinfo, input_base_dir, archive_path, timestamp): # strip first level and replace with generated archive root dir name - tinfo.name = str(Path(archive_path, *Path(tinfo.name).parts[1:])) + input_path = (Path('/') / tinfo.name).relative_to(input_base_dir) + tinfo.name = str(Path(archive_path) / input_path) # be safe tinfo.uid = 0 tinfo.gid = 0