@@ -107,13 +107,10 @@ def __init__(self, job, output_callback, cachebuilder, jobcache):
107
107
108
108
def run (self , ** kwargs ):
109
109
# type: (**Any) -> None
110
- compute_checksum = kwargs .get ("compute_checksum" )
111
- if compute_checksum == None :
112
- compute_checksum = True
113
110
self .output_callback (self .job .collect_output_ports (self .job .tool ["outputs" ],
114
111
self .cachebuilder ,
115
112
self .outdir ,
116
- compute_checksum ),
113
+ kwargs . get ( " compute_checksum" , True ) ),
117
114
"success" )
118
115
119
116
# map files to assigned path inside a container. We need to also explicitly
@@ -337,12 +334,9 @@ def rm_pending_output_callback(output_callback, jobcachepending,
337
334
else :
338
335
j .command_line = flatten (map (builder .generate_arg , builder .bindings ))
339
336
340
- compute_checksum = kwargs .get ("compute_checksum" )
341
- if compute_checksum == None :
342
- compute_checksum = True
343
337
j .pathmapper = builder .pathmapper
344
338
j .collect_outputs = partial (
345
- self .collect_output_ports , self .tool ["outputs" ], builder , compute_checksum = compute_checksum )
339
+ self .collect_output_ports , self .tool ["outputs" ], builder , compute_checksum = kwargs . get ( " compute_checksum" , True ) )
346
340
j .output_callback = output_callback
347
341
348
342
yield j
@@ -416,20 +410,19 @@ def collect_output(self, schema, builder, outdir, compute_checksum=True):
416
410
getListing (builder .fs_access , files )
417
411
else :
418
412
with builder .fs_access .open (files ["location" ], "rb" ) as f :
419
- filesize = 0
420
- contents = f .read (CONTENT_LIMIT )
413
+ contents = ""
414
+ if binding .get ("loadContents" ) or compute_checksum :
415
+ contents = f .read (CONTENT_LIMIT )
421
416
if binding .get ("loadContents" ):
422
417
files ["contents" ] = contents
423
418
if compute_checksum :
424
419
checksum = hashlib .sha1 ()
425
420
while contents != "" :
426
421
checksum .update (contents )
427
- filesize += len (contents )
428
422
contents = f .read (1024 * 1024 )
429
423
files ["checksum" ] = "sha1$%s" % checksum .hexdigest ()
430
- else :
431
- f .seek (0 , 2 )
432
- filesize = f .tell ()
424
+ f .seek (0 , 2 )
425
+ filesize = f .tell ()
433
426
files ["size" ] = filesize
434
427
if "format" in schema :
435
428
files ["format" ] = builder .do_eval (schema ["format" ], context = files )
0 commit comments