Skip to content

Commit

Permalink
fix basename being . when it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuali925 committed Dec 6, 2023
1 parent 6abce04 commit 12b3cb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
_, err := os.Lstat(dst)
if !os.IsNotExist(err) {
ext := filepath.Ext(file)
basename := filepath.Base(file[:len(file)-len(ext)])
basename := ""
if len(file) > len(ext) {
basename = filepath.Base(file[:len(file)-len(ext)])
}
var newPath string
for i := 1; !os.IsNotExist(err); i++ {
file = strings.ReplaceAll(gOpts.dupfilefmt, "%f", basename+ext)
Expand Down
5 changes: 4 additions & 1 deletion nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,10 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
continue
} else if !os.IsNotExist(err) {
ext := filepath.Ext(file)
basename := filepath.Base(file[:len(file)-len(ext)])
basename := ""
if len(file) > len(ext) {
basename = filepath.Base(file[:len(file)-len(ext)])
}
var newPath string
for i := 1; !os.IsNotExist(err); i++ {
file = strings.ReplaceAll(gOpts.dupfilefmt, "%f", basename+ext)
Expand Down

0 comments on commit 12b3cb7

Please sign in to comment.