@@ -23,28 +23,30 @@ func init() {
23
23
// The downside is that renaming uname or gname by the OS never takes effect.
24
24
var userMap , groupMap sync.Map // map[int]string
25
25
26
- func statUnix (fi fs.FileInfo , h * Header ) error {
27
- sys , ok := fi .Sys ().(* syscall.Stat_t )
28
- if ! ok {
29
- return nil
30
- }
31
- h .Uid = int (sys .Uid )
32
- h .Gid = int (sys .Gid )
26
+ func statUnix (fi fs.FileInfo , h * Header , useFileInfoNames bool ) error {
27
+ if ! useFileInfoNames {
28
+ sys , ok := fi .Sys ().(* syscall.Stat_t )
29
+ if ! ok {
30
+ return nil
31
+ }
32
+ h .Uid = int (sys .Uid )
33
+ h .Gid = int (sys .Gid )
33
34
34
- // Best effort at populating Uname and Gname.
35
- // The os/user functions may fail for any number of reasons
36
- // (not implemented on that platform, cgo not enabled, etc).
37
- if u , ok := userMap .Load (h .Uid ); ok {
38
- h .Uname = u .(string )
39
- } else if u , err := user .LookupId (strconv .Itoa (h .Uid )); err == nil {
40
- h .Uname = u .Username
41
- userMap .Store (h .Uid , h .Uname )
42
- }
43
- if g , ok := groupMap .Load (h .Gid ); ok {
44
- h .Gname = g .(string )
45
- } else if g , err := user .LookupGroupId (strconv .Itoa (h .Gid )); err == nil {
46
- h .Gname = g .Name
47
- groupMap .Store (h .Gid , h .Gname )
35
+ // Best effort at populating Uname and Gname.
36
+ // The os/user functions may fail for any number of reasons
37
+ // (not implemented on that platform, cgo not enabled, etc).
38
+ if u , ok := userMap .Load (h .Uid ); ok {
39
+ h .Uname = u .(string )
40
+ } else if u , err := user .LookupId (strconv .Itoa (h .Uid )); err == nil {
41
+ h .Uname = u .Username
42
+ userMap .Store (h .Uid , h .Uname )
43
+ }
44
+ if g , ok := groupMap .Load (h .Gid ); ok {
45
+ h .Gname = g .(string )
46
+ } else if g , err := user .LookupGroupId (strconv .Itoa (h .Gid )); err == nil {
47
+ h .Gname = g .Name
48
+ groupMap .Store (h .Gid , h .Gname )
49
+ }
48
50
}
49
51
50
52
h .AccessTime = statAtime (sys )
0 commit comments