Skip to content

Commit d91181f

Browse files
committed
feat: upgrade redb to v3 compatible format
1 parent 8537460 commit d91181f

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

Cargo.lock

Lines changed: 5 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ postcard = { version = "1", default-features = false, features = [
4747
quinn = { package = "iroh-quinn", version = "0.14.0" }
4848
rand = "0.8.5"
4949
rand_core = "0.6.4"
50-
redb = { version = "2.0.0" }
51-
redb_v1 = { package = "redb", version = "1.5.1" }
50+
redb = { version = "2.6.3" }
5251
self_cell = "1.0.3"
5352
serde = { version = "1.0.164", features = ["derive"] }
5453
serde-error = "0.1.3"
@@ -95,3 +94,6 @@ missing_debug_implementations = "warn"
9594
# do. To enable for a crate set `#![cfg_attr(iroh_docsrs,
9695
# feature(doc_cfg))]` in the crate.
9796
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)"] }
97+
98+
[patch.crates-io]
99+
iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "Frando/redb-upgrade" }

src/store/fs.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ed25519_dalek::{SignatureError, VerifyingKey};
1414
use iroh_blobs::Hash;
1515
use rand_core::CryptoRngCore;
1616
use redb::{Database, DatabaseError, ReadableMultimapTable, ReadableTable};
17-
use tracing::warn;
17+
use tracing::{info, warn};
1818

1919
use super::{
2020
pubkeys::MemPublicKeyStore, DownloadPolicy, ImportNamespaceOutcome, OpenError, PublicKeyStore,
@@ -30,7 +30,6 @@ use crate::{
3030
};
3131

3232
mod bounds;
33-
mod migrate_v1_v2;
3433
mod migrations;
3534
mod query;
3635
mod ranges;
@@ -100,11 +99,18 @@ impl Store {
10099
///
101100
/// The file will be created if it does not exist, otherwise it will be opened.
102101
pub fn persistent(path: impl AsRef<Path>) -> Result<Self> {
103-
let db = match Database::create(&path) {
102+
let mut db = match Database::create(&path) {
104103
Ok(db) => db,
105-
Err(DatabaseError::UpgradeRequired(1)) => migrate_v1_v2::run(&path)?,
104+
Err(DatabaseError::UpgradeRequired(1)) => return Err(
105+
anyhow!("Opening the database failed: Upgrading from old format is no longer supported. Use iroh-docs 0.92 to perform the upgrade, then upgrade to the latest release again.")
106+
),
106107
Err(err) => return Err(err.into()),
107108
};
109+
match db.upgrade() {
110+
Ok(true) => info!("Database was upgraded to redb v3 compatible format"),
111+
Ok(false) => {}
112+
Err(err) => warn!("Database upgrade to redb v3 compatible format failed: {err:#}"),
113+
}
108114
Self::new_impl(db)
109115
}
110116

0 commit comments

Comments
 (0)