File tree 1 file changed +12
-3
lines changed 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -295,9 +295,16 @@ type provenanceEnvironment struct {
295
295
func (p * Package ) inTotoMaterials () ([]in_toto.ProvenanceMaterial , error ) {
296
296
res := make ([]in_toto.ProvenanceMaterial , 0 , len (p .Sources ))
297
297
for _ , src := range p .Sources {
298
- if stat , err := os .Lstat (src ); err != nil {
298
+ stat , err := os .Lstat (src );
299
+ if err != nil {
299
300
return nil , err
300
- } else if ! stat .Mode ().IsRegular () {
301
+ }
302
+
303
+ if stat .Mode ().IsDir () {
304
+ continue
305
+ }
306
+
307
+ if ! stat .Mode ().IsRegular () {
301
308
continue
302
309
}
303
310
@@ -326,12 +333,14 @@ func sha256Hash(fn string) (res string, err error) {
326
333
return "" , xerrors .Errorf ("cannot compute hash of %s: %w" , fn , err )
327
334
}
328
335
336
+ defer f .Close ()
337
+
329
338
hash := sha256 .New ()
330
339
_ , err = io .Copy (hash , f )
331
340
if err != nil {
332
341
return "" , xerrors .Errorf ("cannot compute hash of %s: %w" , fn , err )
333
342
}
334
- f . Close ()
343
+
335
344
336
345
return fmt .Sprintf ("%x" , hash .Sum (nil )), nil
337
346
}
You can’t perform that action at this time.
0 commit comments