Skip to content

Commit

Permalink
Merge pull request #209 from jsternberg/stat-clone
Browse files Browse the repository at this point in the history
types: stat clone drops hidden proto fields
  • Loading branch information
tonistiigi authored Sep 26, 2024
2 parents 7189060 + 069baf6 commit 8754824
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion types/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,22 @@ func (s *Stat) Unmarshal(dAtA []byte) error {
}

func (s *Stat) Clone() *Stat {
return proto.Clone(s).(*Stat)
clone := &Stat{
Path: s.Path,
Mode: s.Mode,
Uid: s.Uid,
Gid: s.Gid,
Size: s.Size,
ModTime: s.ModTime,
Linkname: s.Linkname,
Devmajor: s.Devmajor,
Devminor: s.Devminor,
}
if s.Xattrs != nil {
s.Xattrs = make(map[string][]byte, len(s.Xattrs))
for k, v := range s.Xattrs {
clone.Xattrs[k] = v
}
}
return clone
}

0 comments on commit 8754824

Please sign in to comment.