This repository was archived by the owner on Mar 11, 2023. It is now read-only.
File tree 1 file changed +22
-11
lines changed
cmd/pulumi-resource-docker-buildkit 1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -397,19 +397,30 @@ func newContextHash(contextPath string) *contextHash {
397
397
}
398
398
399
399
func (ch * contextHash ) hashPath (path string , fileMode fs.FileMode ) error {
400
- f , err := os .Open (filepath .Join (ch .contextPath , path ))
401
- if err != nil {
402
- return fmt .Errorf ("open %s: %w" , path , err )
403
- }
404
- defer f .Close ()
405
- h := sha256 .New ()
406
- _ , err = io .Copy (h , f )
407
- if err != nil {
408
- return fmt .Errorf ("read %s: %w" , path , err )
409
- }
410
400
ch .input .Write ([]byte (path ))
411
401
ch .input .Write ([]byte (fileMode .String ()))
412
- ch .input .Write (h .Sum (nil ))
402
+
403
+ fullpath := filepath .Join (ch .contextPath , path )
404
+ if fileMode .IsRegular () {
405
+ f , err := os .Open (fullpath )
406
+ if err != nil {
407
+ return fmt .Errorf ("open %s: %w" , path , err )
408
+ }
409
+ defer f .Close ()
410
+ h := sha256 .New ()
411
+ _ , err = io .Copy (h , f )
412
+ if err != nil {
413
+ return fmt .Errorf ("read %s: %w" , path , err )
414
+ }
415
+ ch .input .Write (h .Sum (nil ))
416
+ } else if fileMode & fs .ModeSymlink != 0 {
417
+ dest , err := os .Readlink (fullpath )
418
+ if err != nil {
419
+ return fmt .Errorf ("readlink %s:" )
420
+ }
421
+ ch .input .Write ([]byte (dest ))
422
+ }
423
+
413
424
ch .input .WriteByte (0 )
414
425
return nil
415
426
}
You can’t perform that action at this time.
0 commit comments