pilorama: Fix TreeDrop #805

Merged
fyrchik merged 1 commit from aarifullin/frostfs-node:fix/bforest_tree_drop into master 2023-11-17 10:21:39 +00:00

View file

@ -1115,11 +1115,12 @@ func (t *boltForest) TreeDrop(ctx context.Context, cid cidSDK.ID, treeID string)
c := tx.Cursor()
prefix := make([]byte, 32)
cid.Encode(prefix)
for k, _ := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, _ = c.Next() {
for k, _ := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, _ = c.Seek(prefix) {
err := tx.DeleteBucket(k)
if err != nil {
return err
}
_, _ = c.First() // rewind the cursor to the root page
}
return nil
}