Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" }
14 changes: 10 additions & 4 deletions src/store/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -30,7 +30,6 @@ use crate::{
};

mod bounds;
mod migrate_v1_v2;
mod migrations;
mod query;
mod ranges;
Expand Down Expand Up @@ -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<Path>) -> Result<Self> {
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)
}

Expand Down
Loading