added preload transfer rate

This commit is contained in:
ston1th 2022-10-08 20:35:05 +02:00
commit 470eeb921c
5 changed files with 111 additions and 13 deletions

View file

@ -60,6 +60,7 @@ type file struct {
URI template.HTML
Anchor string
Size string
Rate string
Status int
Prio int
Errc int
@ -95,7 +96,7 @@ func (r *responseInterceptor) Status() int {
return r.status
}
func (r *responseInterceptor) GetPaths(path string, fs *fs.FS, relative bool) (dc dirContents, err error) {
func (r *responseInterceptor) GetPaths(path string, filesystem *fs.FS, relative bool) (dc dirContents, err error) {
buf := r.buf.Bytes()
buf = bytes.ReplaceAll(buf, []byte{'&'}, []byte("&"))
err = xml.Unmarshal(buf, &dc)
@ -123,8 +124,8 @@ func (r *responseInterceptor) GetPaths(path string, fs *fs.FS, relative bool) (d
Name: name,
URI: uri,
Anchor: anchor(p),
Size: fs.FileSize(full),
Status: fs.CacheStatus(full),
Size: filesystem.FileSize(full),
Status: filesystem.CacheStatus(full),
})
}
}
@ -133,12 +134,14 @@ func (r *responseInterceptor) GetPaths(path string, fs *fs.FS, relative bool) (d
return
}
func getPreloads(path string, fs *fs.FS) (dc dirContents) {
func getPreloads(path string, filesystem *fs.FS) (dc dirContents) {
dc.Base = path
for _, p := range fs.Preloads() {
for _, p := range filesystem.Preloads() {
dc.Files = append(dc.Files, file{
Name: template.HTML(p.Name),
URI: template.HTML(p.Name),
Size: fs.FileSize(p.Size),
Rate: p.Rate(),
Status: p.Status,
Prio: p.Prio,
Errc: p.Errc,

View file

@ -24,6 +24,7 @@ Quota: {{.QuotaCur}} / {{.QuotaMax}} GiB
<span class="status-yellow">[queued]</span>
{{end -}}
{{end -}}
<span>{{$s.Rate}}</span>
<span>{{$s.Size}}</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>