Skip to content

Commit cacb3f3

Browse files
authored
Merge pull request #52 from JayYoung2021/JayYoung2021-patch-getNewName
Update getNewName in comm.go
2 parents f55db83 + cd68d64 commit cacb3f3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

trzsz/comm.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,11 @@ func checkDuplicateNames(sourceFiles []*sourceFile) error {
433433
}
434434

435435
func getNewName(path, name string) (string, error) {
436+
const maxNameLen = 255
437+
if len(name) > maxNameLen {
438+
return "", simpleTrzszError("File name too long: %s", name)
439+
}
440+
436441
if _, err := os.Stat(filepath.Join(path, name)); os.IsNotExist(err) {
437442
return name, nil
438443
}
@@ -442,7 +447,7 @@ func getNewName(path, name string) (string, error) {
442447
return newName, nil
443448
}
444449
}
445-
return "", simpleTrzszError("Fail to assign new file name")
450+
return "", simpleTrzszError("Fail to assign new file name to %s", name)
446451
}
447452

448453
type tmuxModeType int

0 commit comments

Comments
 (0)