fixed rare panic

This commit is contained in:
ston1th 2022-09-16 15:39:38 +02:00
commit 00d87ecb5c
2 changed files with 6 additions and 4 deletions

View file

@ -362,6 +362,10 @@ type Metadata struct {
func (md *Metadata) Close() (err error) {
md.mu.Lock()
defer md.mu.Unlock()
return md.close()
}
func (md *Metadata) close() (err error) {
if md.wc != nil {
close(md.wc)
if md.done != nil {
@ -383,9 +387,7 @@ func (md *Metadata) Delete() error {
md.cmu.Lock()
md.Chunks = chunk.Chunks{}
md.cmu.Unlock()
close(md.wc)
md.f.Close()
md.f = nil
md.close()
atomic.StoreInt64(&md.Atime, now())
return md.fs.RemoveDst(md.name)
}