perf(storage)!: optimize cleanup with secondary index

BREAKING CHANGE: This change requires a fresh database. Existing
databases will lack the index, and the cleanup routine will not function
correctly for pre-existing files.

Signed-off-by: skidoodle <contact@albert.lol>
This commit is contained in:
2026-01-18 22:10:07 +01:00
parent e18be18029
commit d18ef48bd4
5 changed files with 73 additions and 27 deletions
+7 -2
View File
@@ -22,8 +22,13 @@ func InitDB(storageDir string) (*bbolt.DB, error) {
}
err = db.Update(func(tx *bbolt.Tx) error {
_, err := tx.CreateBucketIfNotExists([]byte(DBBucketName))
return err
if _, err := tx.CreateBucketIfNotExists([]byte(DBBucketName)); err != nil {
return err
}
if _, err := tx.CreateBucketIfNotExists([]byte(DBBucketIndexName)); err != nil {
return err
}
return nil
})
if err != nil {