implemented priority preloading
This commit is contained in:
parent
86bd1cd1e5
commit
eb6272e411
7 changed files with 134 additions and 107 deletions
|
|
@ -60,6 +60,7 @@ type file struct {
|
|||
URI template.HTML
|
||||
Anchor string
|
||||
Status int
|
||||
Prio int
|
||||
Running bool
|
||||
}
|
||||
|
||||
|
|
@ -136,12 +137,10 @@ func getPreloads(path string, fs *fs.FS) (dc dirContents) {
|
|||
Name: template.HTML(p.Name),
|
||||
URI: template.HTML(p.Name),
|
||||
Status: p.Status,
|
||||
Prio: p.Prio,
|
||||
Running: p.Running,
|
||||
})
|
||||
}
|
||||
slices.SortFunc(dc.Files, func(i, _ file) bool {
|
||||
return i.Running
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,11 +85,16 @@ func (fs *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if !d.IsDir() {
|
||||
if option == "p" || option == "s" {
|
||||
if option == "p" {
|
||||
fs.fs.Preload(p)
|
||||
} else if option == "s" {
|
||||
fs.fs.CancelPreload(p)
|
||||
if option == "p" || option == "i" || option == "d" || option == "s" {
|
||||
switch option {
|
||||
case "p":
|
||||
fs.fs.Preload(p, 0)
|
||||
case "i":
|
||||
fs.fs.Preload(p, 1)
|
||||
case "d":
|
||||
fs.fs.Preload(p, -1)
|
||||
case "s":
|
||||
fs.fs.RemovePreload(p)
|
||||
}
|
||||
rdir := "/"
|
||||
if r.FormValue("r") == "preloads" {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
{{define "body" -}}
|
||||
<pre>[v]: show video
|
||||
[+]: increase priority
|
||||
[-]: decrease priority
|
||||
[s]: stop preloading
|
||||
Quota: {{.QuotaCur}} / {{.QuotaMax}} GiB
|
||||
</pre>
|
||||
|
|
@ -12,7 +14,7 @@ Quota: {{.QuotaCur}} / {{.QuotaMax}} GiB
|
|||
<tr class="listitem">
|
||||
<td class="listpath"><a href="{{$s.URI}}">{{$s.Name}}</a></td>
|
||||
<td class="listoptions">
|
||||
{{if ge $s.Status 0}}<span>{{$s.Status}}%</span>{{end}}<span class="status-{{if $s.Running}}green">[running{{else}}yellow">[queued{{end}}]</span><a href="{{$s.URI}}?o=v">[v]</a><a href="{{$s.Name}}?o=s&r=preloads">[s]</a>
|
||||
{{if ge $s.Status 0}}<span>{{$s.Status}}%</span>{{end}}<span class="status-{{if $s.Running}}green">[running{{else}}yellow">[queued{{end}}]</span><span>{{$s.Prio}}</span><a href="{{$s.URI}}?o=v">[v]</a><a href="{{$s.Name}}?o=s&r=preloads">[s]</a><a href="{{$s.Name}}?o=i&r=preloads">[+]</a><a href="{{$s.Name}}?o=d&r=preloads">[-]</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="spacer"><td colspan="2">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue