Skip to content

Commit cebf47f

Browse files
committed
perf(serverHandler/upload): verify alias conflict only if exists
1 parent 7ff57df commit cebf47f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/serverHandler/upload.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ func (h *handler) saveUploadFiles(authUserName, fsPrefix string, createDir, over
111111
continue
112112
}
113113

114-
fsInfixPart1 := fsInfix
115-
fsInfixSlashIndex := strings.IndexByte(fsInfixPart1, '/')
116-
if fsInfixSlashIndex > 0 {
117-
fsInfixPart1 = fsInfixPart1[0:fsInfixSlashIndex]
118-
}
119-
if containsItem(aliasSubItems, fsInfixPart1) {
120-
errs = append(errs, errors.New("upload: ignore path shadowed by alias "+fsInfix))
121-
continue
114+
if len(aliasSubItems) > 0 {
115+
fsInfixPart1 := fsInfix
116+
fsInfixSlashIndex := strings.IndexByte(fsInfixPart1, '/')
117+
if fsInfixSlashIndex > 0 {
118+
fsInfixPart1 = fsInfixPart1[0:fsInfixSlashIndex]
119+
}
120+
if containsItem(aliasSubItems, fsInfixPart1) {
121+
errs = append(errs, errors.New("upload: ignore path shadowed by alias "+fsInfix))
122+
continue
123+
}
122124
}
123125

124126
filePrefix += "/" + fsInfix

0 commit comments

Comments
 (0)