Skip to content

Commit 95c7d72

Browse files
committed
feat: upgrade redb to v3 compatible format
1 parent 547a685 commit 95c7d72

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ postcard = { version = "1", default-features = false, features = [
4646
] }
4747
quinn = { package = "iroh-quinn", version = "0.14.0" }
4848
rand = "0.9.2"
49-
redb = { version = "2.0.0" }
50-
redb_v1 = { package = "redb", version = "1.5.1" }
49+
redb = { version = "2.6.3" }
5150
self_cell = "1.0.3"
5251
serde = { version = "1.0.164", features = ["derive"] }
5352
serde-error = "0.1.3"

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::CryptoRng;
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)