do moving GC if the user asks for it

This commit is contained in:
vyzo 2021-07-23 22:44:54 +03:00
parent a843665132
commit c747f2f1e2

View File

@ -477,6 +477,32 @@ func (b *Blockstore) CollectGarbage(options map[interface{}]interface{}) error {
}
defer b.viewers.Done()
var movingGC bool
movingGCOpt, ok := options[blockstore.BlockstoreMovingGC]
if ok {
movingGC, ok = movingGCOpt.(bool)
if !ok {
return fmt.Errorf("incorrect type for moving gc option; expected bool but got %T", movingGCOpt)
}
}
if !movingGC {
return b.onlineGC()
}
var movingGCPath string
movingGCPathOpt, ok := options[blockstore.BlockstoreMovingGCPath]
if ok {
movingGCPath, ok = movingGCPathOpt.(string)
if !ok {
return fmt.Errorf("incorrect type for moving gc path option; expected string but got %T", movingGCPathOpt)
}
}
return b.moveTo(movingGCPath)
}
func (b *Blockstore) onlineGC() error {
b.lockDB()
defer b.unlockDB()