@@ -391,7 +391,7 @@ def _check_adjust(a_file: CWLObjectType) -> CWLObjectType:
391
391
visit_class (outputObj , ("File" , "Directory" ), _check_adjust )
392
392
393
393
if compute_checksum :
394
- visit_class (outputObj , ("File" ,), functools .partial (compute_checksums , fs_access ))
394
+ visit_class (outputObj , ("File" ,), functools .partial (compute_checksums , fs_access , None ))
395
395
return outputObj
396
396
397
397
@@ -1341,14 +1341,18 @@ def scandeps(
1341
1341
return r
1342
1342
1343
1343
1344
- def compute_checksums (fs_access : StdFsAccess , fileobj : CWLObjectType ) -> None :
1344
+ def compute_checksums (fs_access : StdFsAccess , builder : Builder , fileobj : CWLObjectType ) -> None :
1345
1345
if "checksum" not in fileobj :
1346
1346
checksum = hashlib .sha1 () # nosec
1347
- location = cast (str , fileobj ["location" ])
1348
- with fs_access .open (location , "rb" ) as f :
1347
+ location = file_path = cast (str , fileobj ["location" ])
1348
+ if builder :
1349
+ if not builder .pathmapper :
1350
+ raise ValueError ("Do not call compute_checksums using a builder that doesn't have a pathmapper." )
1351
+ file_path = builder .pathmapper .mapper (location )[0 ]
1352
+ with fs_access .open (file_path , "rb" ) as f :
1349
1353
contents = f .read (1024 * 1024 )
1350
1354
while contents != b"" :
1351
1355
checksum .update (contents )
1352
1356
contents = f .read (1024 * 1024 )
1353
1357
fileobj ["checksum" ] = "sha1$%s" % checksum .hexdigest ()
1354
- fileobj ["size" ] = fs_access .size (location )
1358
+ fileobj ["size" ] = fs_access .size (file_path )
0 commit comments