added preload status and cancel
This commit is contained in:
parent
0c9fb06263
commit
a069baf48d
10 changed files with 153 additions and 35 deletions
|
|
@ -17,6 +17,15 @@ type Metadata struct {
|
|||
preload bool `json:"-"`
|
||||
}
|
||||
|
||||
func (md *Metadata) Delete() error {
|
||||
md.mu.Lock()
|
||||
defer md.mu.Unlock()
|
||||
md.Chunks = Chunks{}
|
||||
md.f.Close()
|
||||
md.f = nil
|
||||
return md.fs.RemoveDst(md.name)
|
||||
}
|
||||
|
||||
func (md *Metadata) HasChunk(off int64, n int) bool {
|
||||
md.mu.RLock()
|
||||
defer md.mu.RUnlock()
|
||||
|
|
@ -75,3 +84,13 @@ func (md *Metadata) UnlockPreload() {
|
|||
defer md.mu.Unlock()
|
||||
md.preload = false
|
||||
}
|
||||
|
||||
func (md *Metadata) Stat() (os.FileInfo, error) {
|
||||
if md.f == nil {
|
||||
err := md.openCacheFile()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return md.f.Stat()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue