@@ -76,6 +76,8 @@ type responseData struct {
76
76
IsMkdir bool
77
77
IsDelete bool
78
78
IsMutate bool
79
+ IsArchive bool
80
+ ArchiveFormat string
79
81
80
82
CanIndex bool
81
83
CanUpload bool
@@ -379,6 +381,23 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
379
381
isMutate = true
380
382
}
381
383
384
+ isArchive := false
385
+ archiveFormat := ""
386
+ if len (rawQuery ) == 3 || (len (rawQuery ) > 3 && rawQuery [3 ] == '&' ) {
387
+ rawQuery3 := rawQuery [:3 ]
388
+ switch rawQuery3 {
389
+ case "tar" :
390
+ isArchive = true
391
+ archiveFormat = rawQuery3
392
+ case "tgz" :
393
+ isArchive = true
394
+ archiveFormat = rawQuery3
395
+ case "zip" :
396
+ isArchive = true
397
+ archiveFormat = rawQuery3
398
+ }
399
+ }
400
+
382
401
accepts := acceptHeaders .ParseAccepts (r .Header .Get ("Accept" ))
383
402
_ , preferredContentType , _ := accepts .GetPreferredValue (acceptContentTypes )
384
403
wantJson := preferredContentType == contentTypeJson
@@ -407,8 +426,8 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
407
426
}
408
427
}
409
428
410
- canIndex := authSuccess && h .index .match (vhostReqPath , fsPath , authUserId )
411
- indexFile , indexItem , _statIdxErr := h .statIndexFile (vhostReqPath , fsPath , item , canIndex && redirectAction == noRedirect )
429
+ canIndex := authSuccess && redirectAction == noRedirect && h .index .match (vhostReqPath , fsPath , authUserId )
430
+ indexFile , indexItem , _statIdxErr := h .statIndexFile (vhostReqPath , fsPath , item , canIndex )
412
431
if _statIdxErr != nil {
413
432
errs = append (errs , _statIdxErr )
414
433
status = getStatusByErr (_statIdxErr )
@@ -435,13 +454,13 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
435
454
436
455
itemName := getItemName (item , r )
437
456
438
- subItems , _readdirErr := readdir (file , item , canIndex && ! isMutate && redirectAction == noRedirect && NeedResponseBody (r .Method ))
457
+ subItems , _readdirErr := readdir (file , item , canIndex && ! isMutate && ! isArchive && NeedResponseBody (r .Method ))
439
458
if _readdirErr != nil {
440
459
errs = append (errs , _readdirErr )
441
460
status = http .StatusInternalServerError
442
461
}
443
462
444
- subItems , aliasSubItems , _mergeErrs := h .mergeAlias (vhostReqPath , item , subItems , canIndex && redirectAction == noRedirect )
463
+ subItems , aliasSubItems , _mergeErrs := h .mergeAlias (vhostReqPath , item , subItems , canIndex )
445
464
if len (_mergeErrs ) > 0 {
446
465
errs = append (errs , _mergeErrs ... )
447
466
status = http .StatusInternalServerError
@@ -514,6 +533,8 @@ func (h *aliasHandler) getSessionData(r *http.Request) (session *sessionContext,
514
533
IsMkdir : isMkdir ,
515
534
IsDelete : isDelete ,
516
535
IsMutate : isMutate ,
536
+ IsArchive : isArchive ,
537
+ ArchiveFormat : archiveFormat ,
517
538
518
539
CanIndex : canIndex ,
519
540
CanUpload : canUpload ,
0 commit comments