diff --git a/Cargo.lock b/Cargo.lock index 35657d0..1599bab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1989,8 +1989,7 @@ dependencies = [ [[package]] name = "iroh-blobs" version = "0.94.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1ebaa36eb3a36492c3b661bdd6eaf359f85def358c1c661d2d04edbe4ad5778" +source = "git+https://github.com/n0-computer/iroh-blobs?branch=Frando%2Fredb-upgrade#10d8d40c14af6aae70a950dfe2610d44ce9d4ee4" dependencies = [ "anyhow", "arrayvec", @@ -2014,7 +2013,7 @@ dependencies = [ "postcard", "rand 0.8.5", "range-collections", - "redb 2.4.0", + "redb", "ref-cast", "reflink-copy", "self_cell", @@ -2057,8 +2056,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", - "redb 1.5.1", - "redb 2.4.0", + "redb", "self_cell", "serde", "serde-error", @@ -3565,18 +3563,9 @@ dependencies = [ [[package]] name = "redb" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7f82ecd6ba647a39dd1a7172b8a1cd9453c0adee6da20cb553d83a9a460fa5" -dependencies = [ - "libc", -] - -[[package]] -name = "redb" -version = "2.4.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0a72cd7140de9fc3e318823b883abf819c20d478ec89ce880466dc2ef263c6" +checksum = "8eca1e9d98d5a7e9002d0013e18d5a9b000aee942eb134883a82f06ebffb6c01" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 0ca6e6e..81fefa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,8 +47,7 @@ postcard = { version = "1", default-features = false, features = [ quinn = { package = "iroh-quinn", version = "0.14.0" } rand = "0.8.5" rand_core = "0.6.4" -redb = { version = "2.0.0" } -redb_v1 = { package = "redb", version = "1.5.1" } +redb = { version = "2.6.3" } self_cell = "1.0.3" serde = { version = "1.0.164", features = ["derive"] } serde-error = "0.1.3" @@ -95,3 +94,6 @@ missing_debug_implementations = "warn" # do. To enable for a crate set `#![cfg_attr(iroh_docsrs, # feature(doc_cfg))]` in the crate. unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)"] } + +[patch.crates-io] +iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "Frando/redb-upgrade" } diff --git a/src/store/fs.rs b/src/store/fs.rs index 0ab58e5..38d78bd 100644 --- a/src/store/fs.rs +++ b/src/store/fs.rs @@ -14,7 +14,7 @@ use ed25519_dalek::{SignatureError, VerifyingKey}; use iroh_blobs::Hash; use rand_core::CryptoRngCore; use redb::{Database, DatabaseError, ReadableMultimapTable, ReadableTable}; -use tracing::warn; +use tracing::{info, warn}; use super::{ pubkeys::MemPublicKeyStore, DownloadPolicy, ImportNamespaceOutcome, OpenError, PublicKeyStore, @@ -30,7 +30,6 @@ use crate::{ }; mod bounds; -mod migrate_v1_v2; mod migrations; mod query; mod ranges; @@ -100,11 +99,18 @@ impl Store { /// /// The file will be created if it does not exist, otherwise it will be opened. pub fn persistent(path: impl AsRef) -> Result { - let db = match Database::create(&path) { + let mut db = match Database::create(&path) { Ok(db) => db, - Err(DatabaseError::UpgradeRequired(1)) => migrate_v1_v2::run(&path)?, + Err(DatabaseError::UpgradeRequired(1)) => return Err( + 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.") + ), Err(err) => return Err(err.into()), }; + match db.upgrade() { + Ok(true) => info!("Database was upgraded to redb v3 compatible format"), + Ok(false) => {} + Err(err) => warn!("Database upgrade to redb v3 compatible format failed: {err:#}"), + } Self::new_impl(db) }