Skip to content

Commit 66f4891

Browse files
committed
_relativize picks up checksum, or add if needed
1 parent 55f6ac2 commit 66f4891

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

cwltool/provenance.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,27 +1575,30 @@ def _relativise_files(self, structure):
15751575

15761576
if isinstance(structure, dict):
15771577
if structure.get("class") == "File" and "location" in structure:
1578-
#standardised fs access object creation
1579-
assert self.make_fs_access
1580-
fsaccess = self.make_fs_access("")
1581-
# Store in RO and set "location" as ../data/ab/abcd...
1582-
with fsaccess.open(structure["location"], "rb") as relative_file:
1583-
relative_path = self.add_data_file(relative_file)
1584-
ref_location = structure["location"]
1585-
## FIXME: might this break something else while running wf?
1586-
structure["location"] = "../"+relative_path
1587-
if "path" in structure:
1588-
del structure["path"]
1589-
if "checksum" not in structure:
1590-
# FIXME: This naively relies on add_data_file setting hash as filename
1578+
if "checksum" in structure:
1579+
sha1,checksum = structure["checksum"].split("$")
1580+
assert sha1 == SHA1
1581+
prefix = checksum[0:2]
1582+
relative_path = "../%s/%s" % (prefix,checksum)
1583+
else:
1584+
# Register in RO anyway; but why was this not picked
1585+
# up by used_artefacts?
1586+
_logger.warning("File not previously registered in RO: %s", structure)
1587+
fsaccess = self.make_fs_access("")
1588+
with fsaccess.open(structure["location"], "rb") as fp:
1589+
relative_path = self.add_data_file(fp)
15911590
checksum = posixpath.basename(relative_path)
15921591
structure["checksum"] = "%s$%s" % (SHA1, checksum)
1593-
# TODO: Calculate secondaryFiles if needed but missing
1592+
1593+
# RO-relative path as new location
1594+
structure["location"] = relative_path
1595+
if "path" in structure:
1596+
del structure["path"]
15941597

15951598
if structure.get("class") == "Directory":
15961599
# TODO: Generate anonymoys Directory with a "listing"
15971600
# pointing to the hashed files
1598-
pass
1601+
del structure["location"]
15991602

16001603
for val in structure.values():
16011604
self._relativise_files(val)

0 commit comments

Comments
 (0)