mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
lib: replace Readdir(-1)
with os.ReadDir
(#8901)
This commit is contained in:
parent
b2fb2ef276
commit
089320aadc
@ -1865,13 +1865,7 @@ func (v jsonVersionVector) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func dirNames(dir string) []string {
|
||||
fd, err := os.Open(dir)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer fd.Close()
|
||||
|
||||
fis, err := fd.Readdir(-1)
|
||||
fis, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -200,22 +200,21 @@ func dbIsLarge(location string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
dir, err := os.Open(location)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
fis, err := dir.Readdir(-1)
|
||||
entries, err := os.ReadDir(location)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
var size int64
|
||||
for _, fi := range fis {
|
||||
if fi.Name() == "LOG" {
|
||||
for _, entry := range entries {
|
||||
if entry.Name() == "LOG" {
|
||||
// don't count the size
|
||||
continue
|
||||
}
|
||||
fi, err := entry.Info()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
size += fi.Size()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user