Remove dead code in symlink handling
filepath.Walk uses Lstat, so symlinks are reported with ModeSymlink set, never ModeDir. The info.IsDir() check was always false, making the filepath.SkipDir branch unreachable dead code.
This commit is contained in:
parent
86764abadf
commit
d848c5e51b
11
attrsum.go
11
attrsum.go
@ -397,10 +397,9 @@ func countFiles(root string) int64 {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// Skip symlinks - note: filepath.Walk uses Lstat, so symlinks are
|
||||||
|
// reported as ModeSymlink, never as directories. Walk doesn't follow them.
|
||||||
if info.Mode()&os.ModeSymlink != 0 {
|
if info.Mode()&os.ModeSymlink != 0 {
|
||||||
if info.IsDir() {
|
|
||||||
return filepath.SkipDir
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
rel, _ := filepath.Rel(root, p)
|
rel, _ := filepath.Rel(root, p)
|
||||||
@ -456,14 +455,12 @@ func walkAndProcess(root string, stats *Stats, description string, fn func(strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip symlinks entirely
|
// Skip symlinks - filepath.Walk uses Lstat, so symlinks are reported
|
||||||
|
// as ModeSymlink, never as directories. Walk doesn't follow them.
|
||||||
if info.Mode()&os.ModeSymlink != 0 {
|
if info.Mode()&os.ModeSymlink != 0 {
|
||||||
if verbose && !quiet {
|
if verbose && !quiet {
|
||||||
log.Printf("skip symlink %s", p)
|
log.Printf("skip symlink %s", p)
|
||||||
}
|
}
|
||||||
if info.IsDir() {
|
|
||||||
return filepath.SkipDir
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user