Skip to content

Commit

Permalink
all: replace non-trivial uses of package ioutil with os (ethereum#24886)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Holst Swende <martin@swende.se>
  • Loading branch information
2 people authored and sadoci committed Jan 27, 2023
1 parent 08d1d84 commit 35fbc8f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions accounts/keystore/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
// Gather the set of all and fresly modified files
all.Add(path)

modified := fi.ModTime()
info, err := fi.Info()
if err != nil {
return nil, nil, nil, err
}
modified := info.ModTime()
if modified.After(fc.lastMod) {
mods.Add(path)
}
Expand All @@ -89,13 +93,13 @@ func (fc *fileCache) scan(keyDir string) (mapset.Set, mapset.Set, mapset.Set, er
}

// nonKeyFile ignores editor backups, hidden files and folders/symlinks.
func nonKeyFile(fi os.FileInfo) bool {
func nonKeyFile(fi os.DirEntry) bool {
// Skip editor backups and UNIX-style hidden files.
if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
return true
}
// Skip misc special files, directories (yes, symlinks too).
if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
if fi.IsDir() || !fi.Type().IsRegular() {
return true
}
return false
Expand Down

0 comments on commit 35fbc8f

Please sign in to comment.