Skip to content

Commit

Permalink
fix: strip complete base directory from tarfile paths
Browse files Browse the repository at this point in the history
Strip the complete input base directory from the paths
the are used in the study-visit tar-files.

This commit fixes issue
<#53>
  • Loading branch information
christian-monch committed Jul 5, 2024
1 parent 38b5783 commit a4665f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/make_studyvisit_archive
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit a4665f6

Please sign in to comment.