make linter happier

This commit is contained in:
Lilian Jónsdóttir 2024-07-31 00:13:48 -07:00
parent 747a24ebd6
commit 98a5044662
6 changed files with 21 additions and 28 deletions

View file

@ -27,9 +27,8 @@ func SortByModified(a, b File) int {
return 1
} else if a.Date().After(b.Date()) {
return -1
} else {
return 0
}
return 0
}
func SortByModifiedReverse(a, b File) int {
@ -37,9 +36,8 @@ func SortByModifiedReverse(a, b File) int {
return 1
} else if a.Date().Before(b.Date()) {
return -1
} else {
return 0
}
return 0
}
func SortBySize(a, b File) int {
@ -87,9 +85,8 @@ func SortDirectoriesFirst(a, b File) int {
return 1
} else if a.IsDir() && !b.IsDir() {
return -1
} else {
return 0
}
return 0
}
func SortDirectoriesLast(a, b File) int {
@ -97,9 +94,8 @@ func SortDirectoriesLast(a, b File) int {
return 1
} else if !a.IsDir() && b.IsDir() {
return -1
} else {
return 0
}
return 0
}
func doNameSort(a, b File) int {
@ -119,7 +115,6 @@ func doNameSort(a, b File) int {
func getSortingSize(f File) int64 {
if f.IsDir() {
return -1
} else {
return f.Filesize()
}
return f.Filesize()
}

View file

@ -296,19 +296,19 @@ func ensureUniqueName(filename, trashDir string) (string, string) {
// doesn't exist, so use it
path := filepath.Join(filedir, filename)
return info, path
} else {
// otherwise, try random suffixes until one works
log.Debugf("%s exists in trash, generating random name", filename)
var tries int
for {
tries++
rando := randomFilename(randomStrLength)
newName := filepath.Join(infodir, filename+rando+trashInfoExt)
if _, err := os.Stat(newName); os.IsNotExist(err) {
path := filepath.Join(filedir, filename+rando)
log.Debugf("settled on random name %s%s on the %s try", filename, rando, humanize.Ordinal(tries))
return newName, path
}
}
// otherwise, try random suffixes until one works
log.Debugf("%s exists in trash, generating random name", filename)
var tries int
for {
tries++
rando := randomFilename(randomStrLength)
newName := filepath.Join(infodir, filename+rando+trashInfoExt)
if _, err := os.Stat(newName); os.IsNotExist(err) {
path := filepath.Join(filedir, filename+rando)
log.Debugf("settled on random name %s%s on the %s try", filename, rando, humanize.Ordinal(tries))
return newName, path
}
}
}