mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 13:56:37 +08:00
优化,现有bug处理
This commit is contained in:
@@ -14,14 +14,22 @@ type walkInfo struct {
|
||||
}
|
||||
|
||||
// walk traverses root depth-first calling fn for every entry. Hidden
|
||||
// directories (starting with ".") are skipped.
|
||||
// directories (starting with ".") below the root are skipped.
|
||||
//
|
||||
// The root itself is deliberately exempt from the hidden-directory rule.
|
||||
// WalkDir reports the root with its own base name, so a root such as
|
||||
// "/media/.staging" used to match the hidden check and yield filepath.SkipDir
|
||||
// immediately — the entire tree was skipped silently, with no error and no
|
||||
// warning. A library or organize source may legitimately live in a
|
||||
// dot-prefixed directory, so only children are filtered.
|
||||
func walk(root string, fn func(string, walkInfo) error) error {
|
||||
return filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
|
||||
rootPath := filepath.Clean(root)
|
||||
return filepath.WalkDir(rootPath, func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return nil // best effort — keep walking
|
||||
}
|
||||
name := d.Name()
|
||||
if d.IsDir() && name != "." && len(name) > 1 && name[0] == '.' {
|
||||
if d.IsDir() && path != rootPath && name != "." && len(name) > 1 && name[0] == '.' {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
info := walkInfo{isDir: d.IsDir()}
|
||||
|
||||
Reference in New Issue
Block a user