pub fn open_or_recreate_redb(path: &Path) -> Result<Database, DatabaseError>Expand description
Open a redb Database at path, recreating the file when it has a
stale on-disk schema.
redb’s file format changes between major versions (we recently bumped
2.x → 4.x). Opening a file written by the previous major returns
DatabaseError::UpgradeRequired(_) and there is no automatic in-place
migration. Every redb file the app maintains is derivative state —
the SWR cache and the multipart-upload bookkeeping table — that can be
safely wiped and rebuilt at runtime; the alternative (panicking and
refusing to launch) is far worse for the user than losing a cache and
orphaning a handful of multipart uploads (which the MultipartPanel can
still clean up by scanning S3 directly).
Retry strategy:
Database::create(path)(opens existing or creates new).- If
UpgradeRequired→ remove the file and callcreateagain. - Any other error propagates unchanged.