Skip to content

Commit 0d65917

Browse files
committed
corrected ../data relative path
1 parent ceabc73 commit 0d65917

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

cwltool/provenance.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,24 +1561,29 @@ def relativise_files(self, structure):
15611561
_logger.debug(u"[provenance] Relativising: %s", structure)
15621562

15631563
if isinstance(structure, dict):
1564-
if structure.get("class") == "File" and "location" in structure:
1564+
if structure.get("class") == "File":
1565+
relative_path = None
15651566
if "checksum" in structure:
15661567
sha1,checksum = structure["checksum"].split("$")
15671568
assert sha1 == SHA1
1568-
prefix = checksum[0:2]
1569-
relative_path = "../data/%s/%s" % (prefix,checksum)
1570-
else:
1571-
# Register in RO anyway; but why was this not picked
1569+
if self.has_data_file(checksum):
1570+
prefix = checksum[0:2]
1571+
relative_path = posixpath.join("data", prefix, checksum)
1572+
1573+
if not relative_path and "location" in structure:
1574+
# Register in RO; but why was this not picked
15721575
# up by used_artefacts?
15731576
_logger.warning("File not previously registered in RO: %s", structure)
15741577
fsaccess = self.make_fs_access("")
15751578
with fsaccess.open(structure["location"], "rb") as fp:
15761579
relative_path = self.add_data_file(fp)
15771580
checksum = posixpath.basename(relative_path)
15781581
structure["checksum"] = "%s$%s" % (SHA1, checksum)
1579-
1580-
# RO-relative path as new location
1581-
structure["location"] = relative_path
1582+
if relative_path:
1583+
# RO-relative path as new location
1584+
structure["location"] = posixpath.join("..", relative_path)
1585+
else:
1586+
_logger.warning("Could not determine RO path for file %s", structure)
15821587
if "path" in structure:
15831588
del structure["path"]
15841589

0 commit comments

Comments
 (0)