Skip to content

Commit

Permalink
chore: annotate errors returned from NewFromStat() with the file path
Browse files Browse the repository at this point in the history
Otherwise it is very tricky to understand which file produced the error.
Should help with docker/for-win#14083
  • Loading branch information
fiam committed Jan 14, 2025
1 parent dd06922 commit 99ea674
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cache/contenthash/filehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"time"

"github.com/pkg/errors"
fstypes "github.com/tonistiigi/fsutil/types"
)

Expand Down Expand Up @@ -46,7 +47,7 @@ func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
fi := &statInfo{stat}
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
if err != nil {
return nil, err
return nil, errors.Wrapf(err, "failed to stat file %s", stat.Path)
}
hdr.Name = "" // note: empty name is different from current has in docker build. Name is added on recursive directory scan instead
hdr.Devmajor = stat.Devmajor
Expand Down

0 comments on commit 99ea674

Please sign in to comment.