Former-commit-id: 35d375188e7c700484d32a27eb48b30192e20537
This commit is contained in:
Henrique Dias
2017-01-03 15:10:33 +00:00
parent 5fc83eff7e
commit f1f248e4d6
10 changed files with 160 additions and 99 deletions

View File

@@ -136,7 +136,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
// If it's a dir and the path doesn't end with a trailing slash,
// redirect the user.
if fi.IsDir() && !strings.HasSuffix(r.URL.Path, "/") {
if fi.IsDir && !strings.HasSuffix(r.URL.Path, "/") {
http.Redirect(w, r, c.AddrPath+r.URL.Path+"/", http.StatusTemporaryRedirect)
return 0, nil
}
@@ -144,10 +144,10 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
switch {
case r.URL.Query().Get("download") != "":
code, err = handlers.Download(w, r, c, fi)
case r.URL.Query().Get("raw") == "true" && !fi.IsDir():
case r.URL.Query().Get("raw") == "true" && !fi.IsDir:
http.ServeFile(w, r, fi.Path)
code, err = 0, nil
case fi.IsDir():
case fi.IsDir:
code, err = handlers.ServeListing(w, r, c, user, fi)
default:
code, err = handlers.ServeSingle(w, r, c, user, fi)