fix(server): Improve namin

This commit is contained in:
Myzel394 2025-05-29 20:22:57 +02:00
parent a2decaeff3
commit ac97ec77ef
No known key found for this signature in database
GPG Key ID: 3B955307C2FC2F11

View File

@ -50,13 +50,13 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
} }
} }
fileRequired := (v.RequiredType & PathTypeFile) == PathTypeFile fileExpected := (v.RequiredType & PathTypeFile) == PathTypeFile
directoryRequired := (v.RequiredType & PathTypeDirectory) == PathTypeDirectory directoryExpected := (v.RequiredType & PathTypeDirectory) == PathTypeDirectory
isValid := true isValid := true
// If file is expected // If file is expected
if fileRequired { if fileExpected {
// and exists // and exists
isValid = isValid && utils.IsPathFile(value) isValid = isValid && utils.IsPathFile(value)
// file not expected // file not expected
@ -66,7 +66,7 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
} }
// if directory // if directory
if directoryRequired { if directoryExpected {
// and exists // and exists
isValid = isValid && utils.IsPathDirectory(value) isValid = isValid && utils.IsPathDirectory(value)
// directory not expected // directory not expected
@ -79,21 +79,21 @@ func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue {
return nil return nil
} }
if fileRequired && directoryRequired { if fileExpected && directoryExpected {
return []*InvalidValue{{ return []*InvalidValue{{
Err: errors.New("This must be either a file or a directory"), Err: errors.New("This must be either a file or a directory"),
Start: 0, Start: 0,
End: uint32(len(value)), End: uint32(len(value)),
}} }}
} }
if fileRequired { if fileExpected {
return []*InvalidValue{{ return []*InvalidValue{{
Err: errors.New("This must be a file"), Err: errors.New("This must be a file"),
Start: 0, Start: 0,
End: uint32(len(value)), End: uint32(len(value)),
}} }}
} }
if directoryRequired { if directoryExpected {
return []*InvalidValue{{ return []*InvalidValue{{
Err: errors.New("This must be a directory"), Err: errors.New("This must be a directory"),
Start: 0, Start: 0,