Skip to content

Commit

Permalink
fix basename being . when it is empty (#1525)
Browse files Browse the repository at this point in the history
* fix basename being `.` when it is empty

* remove unnecessary call of `filepath.Base`
  • Loading branch information
joshuali925 authored Dec 11, 2023
1 parent cbdae8e commit 31f4a4e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ 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 := 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
2 changes: 1 addition & 1 deletion nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ 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 := 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 31f4a4e

Please sign in to comment.