Skip to content

Commit

Permalink
Update getNewName in comm.go
Browse files Browse the repository at this point in the history
Add check of over-long filename and corresponding error throw.
Add output of filename that cannot be assigned a new filename.
  • Loading branch information
JayYoung2021 authored Apr 19, 2024
1 parent f55db83 commit cd68d64
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion trzsz/comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ func checkDuplicateNames(sourceFiles []*sourceFile) error {
}

func getNewName(path, name string) (string, error) {
const maxNameLen = 255
if len(name) > maxNameLen {
return "", simpleTrzszError("File name too long: %s", name)
}

if _, err := os.Stat(filepath.Join(path, name)); os.IsNotExist(err) {
return name, nil
}
Expand All @@ -442,7 +447,7 @@ func getNewName(path, name string) (string, error) {
return newName, nil
}
}
return "", simpleTrzszError("Fail to assign new file name")
return "", simpleTrzszError("Fail to assign new file name to %s", name)
}

type tmuxModeType int
Expand Down

0 comments on commit cd68d64

Please sign in to comment.