9 "github.com/docker/docker/pkg/archive"
10 "github.com/docker/docker/pkg/tarsum"
13 // NewFileHash returns new hash that is used for the builder cache keys
14 func NewFileHash(path, name string, fi os.FileInfo) (hash.Hash, error) {
16 if fi.Mode()&os.ModeSymlink != 0 {
18 link, err = os.Readlink(path)
23 hdr, err := archive.FileInfoHeader(name, fi, link)
27 if err := archive.ReadSecurityXattrToTarHeader(path, hdr); err != nil {
30 tsh := &tarsumHash{hdr: hdr, Hash: sha256.New()}
31 tsh.Reset() // initialize header
35 type tarsumHash struct {
40 // Reset resets the Hash to its initial state.
41 func (tsh *tarsumHash) Reset() {
42 // comply with hash.Hash and reset to the state hash had before any writes
44 tarsum.WriteV1Header(tsh.hdr, tsh.Hash)