@@ -48,16 +48,17 @@ type Directory struct {
4848}
4949
5050type HTTPStaticServer struct {
51- Root string
52- Prefix string
53- Upload bool
54- Delete bool
55- Title string
56- Theme string
57- PlistProxy string
58- GoogleTrackerID string
59- AuthType string
60- NoIndex bool
51+ Root string
52+ Prefix string
53+ Upload bool
54+ Delete bool
55+ Title string
56+ Theme string
57+ PlistProxy string
58+ GoogleTrackerID string
59+ AuthType string
60+ DeepPathMaxDepth int
61+ NoIndex bool
6162
6263 indexes []IndexFileItem
6364 m * mux.Router
@@ -575,6 +576,7 @@ func (s *HTTPStaticServer) hJSONList(w http.ResponseWriter, r *http.Request) {
575576 auth := s .readAccessConf (realPath )
576577 auth .Upload = auth .canUpload (r )
577578 auth .Delete = auth .canDelete (r )
579+ maxDepth := s .DeepPathMaxDepth
578580
579581 // path string -> info os.FileInfo
580582 fileInfoMap := make (map [string ]os.FileInfo , 0 )
@@ -619,7 +621,7 @@ func (s *HTTPStaticServer) hJSONList(w http.ResponseWriter, r *http.Request) {
619621 lr .Name = filepath .ToSlash (name ) // fix for windows
620622 }
621623 if info .IsDir () {
622- name := deepPath (realPath , info .Name ())
624+ name := deepPath (realPath , info .Name (), maxDepth )
623625 lr .Name = name
624626 lr .Path = filepath .Join (filepath .Dir (path ), name )
625627 lr .Type = "dir"
@@ -744,9 +746,8 @@ func (s *HTTPStaticServer) readAccessConf(realPath string) (ac AccessConf) {
744746 return
745747}
746748
747- func deepPath (basedir , name string ) string {
749+ func deepPath (basedir , name string , maxDepth int ) string {
748750 // loop max 5, incase of for loop not finished
749- maxDepth := 5
750751 for depth := 0 ; depth <= maxDepth ; depth += 1 {
751752 finfos , err := ioutil .ReadDir (filepath .Join (basedir , name ))
752753 if err != nil || len (finfos ) != 1 {
0 commit comments