Skip to content

Commit 2ee09c7

Browse files
committed
perf(serverHandler): skip merge alias if respond file content
1 parent f4dd317 commit 2ee09c7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/serverHandler/responseData.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ func readdir(file *os.File, item os.FileInfo, visitFs bool) (subItems []os.FileI
121121
return file.Readdir(0)
122122
}
123123

124-
func (h *handler) mergeAlias(rawRequestPath string, subItems *[]os.FileInfo) []error {
124+
func (h *handler) mergeAlias(item os.FileInfo, rawRequestPath string, subItems *[]os.FileInfo) []error {
125125
errs := []error{}
126126

127+
if item == nil || !item.IsDir() {
128+
return errs
129+
}
130+
127131
for _, alias := range h.aliases {
128132
aliasUrlPath := alias.urlPath
129133
aliasFsPath := alias.fsPath
@@ -307,7 +311,7 @@ func (h *handler) getResponseData(r *http.Request) (data *responseData) {
307311
status = http.StatusInternalServerError
308312
}
309313

310-
_mergeErrs := h.mergeAlias(rawReqPath, &subInfos)
314+
_mergeErrs := h.mergeAlias(item, rawReqPath, &subInfos)
311315
if len(_mergeErrs) > 0 {
312316
errs = append(errs, _mergeErrs...)
313317
status = http.StatusInternalServerError

0 commit comments

Comments
 (0)