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

@ -10,8 +10,8 @@ import (
const sep = string(os.PathSeparator)
var (
home string = os.Getenv("HOME")
pwd, _ = os.Getwd()
home = os.Getenv("HOME")
pwd, _ = os.Getwd()
)
// UnExpand returns dir after expanding some directory shortcuts

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
}
}
}

View file

@ -312,7 +312,6 @@ func (m model) View() string {
}
func (m model) showHelp() string {
// TODO: maybe use bubbletea built in help
var filterText string
if m.filter != "" {
filterText = fmt.Sprintf(" (%s)", m.filter)

View file

@ -11,8 +11,6 @@ import (
"golang.org/x/term"
)
// TODO: use charm stuff for this
func YesNo(prompt string) bool {
return AskRune(prompt, "y/n") == 'y'
}

View file

@ -1,3 +1,4 @@
// Package main does the thing
package main
import (