added preload status and cancel
This commit is contained in:
parent
0c9fb06263
commit
a069baf48d
10 changed files with 153 additions and 35 deletions
|
|
@ -8,6 +8,8 @@ import (
|
|||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"cachefs/pkg/fs"
|
||||
)
|
||||
|
||||
type statusInterceptor struct {
|
||||
|
|
@ -44,6 +46,7 @@ type dirContents struct {
|
|||
type file struct {
|
||||
Name string
|
||||
Anchor string
|
||||
Status int
|
||||
}
|
||||
|
||||
type files []file
|
||||
|
|
@ -77,16 +80,21 @@ func (r *responseInterceptor) Status() int {
|
|||
return r.status
|
||||
}
|
||||
|
||||
func (r *responseInterceptor) GetPaths() (dir dirContents, err error) {
|
||||
func (r *responseInterceptor) GetPaths(path string, fs *fs.FS) (dir dirContents, err error) {
|
||||
err = xml.Unmarshal(r.buf.Bytes(), &dir)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
path = strings.TrimSuffix(path, "/")
|
||||
for _, p := range dir.AllPaths {
|
||||
if p[len(p)-1] == '/' {
|
||||
dir.Dirs = append(dir.Dirs, p)
|
||||
} else {
|
||||
dir.Files = append(dir.Files, file{Name: p, Anchor: anchor(p)})
|
||||
dir.Files = append(dir.Files, file{
|
||||
Name: p,
|
||||
Anchor: anchor(p),
|
||||
Status: fs.CacheStatus(path + "/" + p),
|
||||
})
|
||||
}
|
||||
}
|
||||
sort.Strings(dir.Dirs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue