added preload status and cancel
This commit is contained in:
parent
0c9fb06263
commit
a069baf48d
10 changed files with 153 additions and 35 deletions
|
|
@ -57,7 +57,8 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, msg, code)
|
||||
return
|
||||
}
|
||||
if r.FormValue("v") == "t" {
|
||||
option := r.FormValue("o")
|
||||
if option == "v" {
|
||||
err = video.Execute(w, r.URL.Path)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
@ -66,8 +67,12 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if !d.IsDir() {
|
||||
if r.FormValue("p") == "t" {
|
||||
fs.fs.Preload(p)
|
||||
if option == "p" || option == "sp" {
|
||||
if option == "p" {
|
||||
fs.fs.Preload(p)
|
||||
} else {
|
||||
fs.fs.CancelPreload(p)
|
||||
}
|
||||
rdir := "/"
|
||||
if i := strings.LastIndex(p, "/"); i > 0 {
|
||||
rdir = p[:i]
|
||||
|
|
@ -75,7 +80,7 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
http.Redirect(w, r, rdir+"#"+anchor(p), http.StatusFound)
|
||||
return
|
||||
}
|
||||
if r.FormValue("n") == "t" {
|
||||
if option == "n" {
|
||||
fs.fs.NoCache.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
|
@ -94,7 +99,7 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
if offline {
|
||||
w.Header().Del("Last-Modified")
|
||||
}
|
||||
paths, err := i.GetPaths()
|
||||
paths, err := i.GetPaths(p, fs.fs)
|
||||
if err == io.EOF {
|
||||
w.WriteHeader(i.Status())
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue