This commit is contained in:
Timofey.Kovalev 2018-09-24 12:59:41 +03:00
parent b5063758e5
commit d0769b2cb3

View File

@ -100,7 +100,12 @@ func dirList(w http.ResponseWriter, r *http.Request, f http.File, name string) {
renderError(w, "Error reading directory", http.StatusInternalServerError)
return
}
sort.Slice(dirs, func(i, j int) bool { return dirs[i].Name() < dirs[j].Name() })
sort.Slice(dirs, func(i, j int) bool {
if dirs[i].IsDir() && !dirs[j].IsDir() {
return true
}
return dirs[i].Name() < dirs[j].Name()
})
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@ -112,6 +117,7 @@ func dirList(w http.ResponseWriter, r *http.Request, f http.File, name string) {
data := &Data{
Title: name,
IsRoot: name == "/",
Files: make([]*File, 0, len(dirs)),
}