added preloads page
This commit is contained in:
parent
b5ae5504a7
commit
333d5cb149
6 changed files with 235 additions and 75 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue