added preloads page

This commit is contained in:
ston1th 2022-03-23 01:09:12 +01:00
commit 333d5cb149
6 changed files with 235 additions and 75 deletions

View file

@ -16,14 +16,13 @@ func now() int64 {
type MetadataMap map[string]*Metadata
type Metadata struct {
mu sync.RWMutex `json:"-"`
fs *FS `json:"-"`
f *os.File `json:"-"`
name string `json:"-"`
Size int64 `json:"s"`
Atime int64 `json:"a"`
Chunks Chunks `json:"c"`
preload bool `json:"-"`
mu sync.RWMutex `json:"-"`
fs *FS `json:"-"`
f *os.File `json:"-"`
name string `json:"-"`
Size int64 `json:"s"`
Atime int64 `json:"a"`
Chunks Chunks `json:"c"`
}
func (md *Metadata) Delete() error {
@ -82,22 +81,6 @@ func (md *Metadata) openCacheFile() error {
return err
}
func (md *Metadata) Preload() bool {
md.mu.Lock()
defer md.mu.Unlock()
if md.preload {
return true
}
md.preload = true
return false
}
func (md *Metadata) UnlockPreload() {
md.mu.Lock()
defer md.mu.Unlock()
md.preload = false
}
func (md *Metadata) Stat() (os.FileInfo, error) {
if md.f == nil {
err := md.openCacheFile()