Skip to content

Commit f7a5cd7

Browse files
committed
as per wxiaoguang
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 55c4ec6 commit f7a5cd7

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

modules/options/base.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ func walkAssetDir(root string, callback func(path, name string, d fs.DirEntry, e
2626
}
2727
return err
2828
}
29-
if d.IsDir() && util.CommonSkipDir(d.Name()) {
30-
return fs.SkipDir
29+
if util.CommonSkip(d.Name()) {
30+
if d.IsDir() {
31+
return fs.SkipDir
32+
}
33+
return nil
3134
}
3235
return callback(path, name, d, err)
3336
}); err != nil && !os.IsNotExist(err) {

modules/templates/base.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ func walkAssetDir(root string, skipMail bool, callback func(path, name string, d
111111
if skipMail && path == mailRoot && d.IsDir() {
112112
return fs.SkipDir
113113
}
114-
if d.IsDir() && util.CommonSkipDir(d.Name()) { // Because Macs...
115-
return fs.SkipDir
114+
if util.CommonSkip(d.Name()) {
115+
if d.IsDir() {
116+
return fs.SkipDir
117+
}
118+
return nil
116119
}
117120
if strings.HasSuffix(d.Name(), ".tmpl") || d.IsDir() {
118121
return callback(path, name, d, err)

modules/util/path.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func statDir(dirPath, recPath string, includeDir, isDirOnly, followSymlinks bool
9090

9191
statList := make([]string, 0)
9292
for _, fi := range fis {
93-
if fi.IsDir() && CommonSkipDir(fi.Name()) {
93+
if CommonSkip(fi.Name()) {
9494
continue
9595
}
9696

@@ -199,8 +199,20 @@ func HomeDir() (home string, err error) {
199199
return home, nil
200200
}
201201

202-
// CommonSkipDir will check a provided name to see if it represents directory that should not be watched
203-
func CommonSkipDir(name string) bool {
204-
// Check for Mac's .DS_Store entries
205-
return name == ".DS_Store"
202+
// CommonSkip will check a provided name to see if it represents file or directory that should not be watched
203+
func CommonSkip(name string) bool {
204+
if name == "" {
205+
return true
206+
}
207+
208+
switch name[0] {
209+
case '.':
210+
return true
211+
case 't', 'T':
212+
return name[1:] == "humbs.db"
213+
case 'd', 'D':
214+
return name[1:] == "esktop.ini"
215+
}
216+
217+
return false
206218
}

0 commit comments

Comments
 (0)