archive/tar: make use of maps.Clone

Change-Id: I5c5b051460a43779bfe30c48d694b789992fa10e
This commit is contained in:
Jes Cok 2024-09-13 00:23:10 +08:00
parent 8a4b439ee6
commit 20a56b4161
1 changed files with 3 additions and 12 deletions

View File

@ -15,6 +15,7 @@ import (
"fmt"
"internal/godebug"
"io/fs"
"maps"
"math"
"path"
"reflect"
@ -696,24 +697,14 @@ func FileInfoHeader(fi fs.FileInfo, link string) (*Header, error) {
h.Gname = sys.Gname
h.AccessTime = sys.AccessTime
h.ChangeTime = sys.ChangeTime
if sys.Xattrs != nil {
h.Xattrs = make(map[string]string)
for k, v := range sys.Xattrs {
h.Xattrs[k] = v
}
}
h.Xattrs = maps.Clone(sys.Xattrs)
if sys.Typeflag == TypeLink {
// hard link
h.Typeflag = TypeLink
h.Size = 0
h.Linkname = sys.Linkname
}
if sys.PAXRecords != nil {
h.PAXRecords = make(map[string]string)
for k, v := range sys.PAXRecords {
h.PAXRecords[k] = v
}
}
h.PAXRecords = maps.Clone(sys.PAXRecords)
}
var doNameLookups = true
if iface, ok := fi.(FileInfoNames); ok {