Skip to content

Commit

Permalink
Merge pull request #52 from JayYoung2021/JayYoung2021-patch-getNewName
Browse files Browse the repository at this point in the history
Update getNewName in comm.go
  • Loading branch information
lonnywong authored Apr 22, 2024
2 parents f55db83 + cd68d64 commit cacb3f3
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 cacb3f3

Please sign in to comment.