holiman / billy

Very simple datastore
BSD 3-Clause "New" or "Revised" License
50 stars 7 forks source link

Make OnDataFn return error, delete item if so? #4

Closed karalabe closed 1 year ago

karalabe commented 1 year ago

When doing the initial indexing, in theory it can happen that the item is non-parseable (e.g. we change the data format we store on disk). In that case, we won't be able to parse the item in OnDataFn and would be nice to allow deleting it instead.

Since startup and deletion might conflict, it perhaps would be simpler to allow returning an error which would implicitly remove the item from disk. Currently the best I can do is "ignore" the item on startup, collect the "faulty" indixes and then iterate over them and delete them one by one, which feels a bit wonky.

Then again, returning an error causing a deletion is also a bit wonky if there's just a parsing bug or similar weirdness. Open for discussion

karalabe commented 1 year ago

Ok, on second thought, deleting data items implicitly seems a bad idea, forget it.