@@ -135,10 +135,11 @@ func (h *handler) mergeAlias(
135135 rawRequestPath string ,
136136 item os.FileInfo ,
137137 subItems []os.FileInfo ,
138+ doMerge bool ,
138139) (mergedSubItems , aliasSubItems []os.FileInfo , errs []error ) {
139140 errs = []error {}
140141
141- if (item != nil && ! item .IsDir ()) || len (h .aliases ) == 0 {
142+ if ! doMerge || (item != nil && ! item .IsDir ()) || len (h .aliases ) == 0 {
142143 return subItems , nil , errs
143144 }
144145
@@ -223,8 +224,8 @@ func getStatusByErr(err error) int {
223224 }
224225}
225226
226- func (h * handler ) stateIndexFile (rawReqPath , baseDir string , baseItem os.FileInfo ) (file * os.File , item os.FileInfo , err error ) {
227- if len (h .dirIndexes ) == 0 {
227+ func (h * handler ) statIndexFile (rawReqPath , baseDir string , baseItem os.FileInfo , doStat bool ) (file * os.File , item os.FileInfo , err error ) {
228+ if ! doStat || len (h .dirIndexes ) == 0 {
228229 return
229230 }
230231
@@ -326,7 +327,7 @@ func (h *handler) getResponseData(r *http.Request) *responseData {
326327 status = getStatusByErr (_statErr )
327328 }
328329
329- indexFile , indexItem , _statIdxErr := h .stateIndexFile (rawReqPath , reqFsPath , item )
330+ indexFile , indexItem , _statIdxErr := h .statIndexFile (rawReqPath , reqFsPath , item , authSuccess )
330331 if _statIdxErr != nil {
331332 errs = append (errs , _statIdxErr )
332333 status = getStatusByErr (_statIdxErr )
@@ -348,7 +349,7 @@ func (h *handler) getResponseData(r *http.Request) *responseData {
348349 status = http .StatusInternalServerError
349350 }
350351
351- subItems , aliasSubItems , _mergeErrs := h .mergeAlias (rawReqPath , item , subItems )
352+ subItems , aliasSubItems , _mergeErrs := h .mergeAlias (rawReqPath , item , subItems , authSuccess )
352353 if len (_mergeErrs ) > 0 {
353354 errs = append (errs , _mergeErrs ... )
354355 status = http .StatusInternalServerError
0 commit comments