mirror of
https://github.com/ShadowJonathan/conduit_toolbox.git
synced 2025-07-19 01:59:31 +03:00
only ignore broken rows upon request
This commit is contained in:
parent
31ce64ea72
commit
4a48ab3b50
3 changed files with 48 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
use clap::{App, Arg};
|
||||
use conduit_iface::db::{self, copy_database};
|
||||
use conduit_iface::db::{self, copy_database, Config};
|
||||
use std::{
|
||||
ops::{Deref, DerefMut},
|
||||
path::{Path, PathBuf},
|
||||
|
@ -19,14 +19,17 @@ enum Database {
|
|||
}
|
||||
|
||||
impl Database {
|
||||
fn new(name: &str, path: PathBuf) -> anyhow::Result<Self> {
|
||||
fn new(name: &str, path: PathBuf, config: Config) -> anyhow::Result<Self> {
|
||||
Ok(match name {
|
||||
#[cfg(feature = "sled")]
|
||||
"sled" => Self::Sled(db::sled::SledDB::new(db::sled::new_db(path)?)),
|
||||
#[cfg(feature = "heed")]
|
||||
"heed" => Self::Heed(db::heed::HeedDB::new(db::heed::new_db(path)?)),
|
||||
#[cfg(feature = "sqlite")]
|
||||
"sqlite" => Self::Sqlite(db::sqlite::SqliteDB::new(db::sqlite::new_conn(path)?)),
|
||||
"sqlite" => Self::Sqlite(db::sqlite::SqliteDB::new(
|
||||
db::sqlite::new_conn(path)?,
|
||||
config,
|
||||
)),
|
||||
#[cfg(feature = "rocksdb")]
|
||||
"rocks" => Self::Rocks(db::rocksdb::new_conn(path)?),
|
||||
#[cfg(feature = "persy")]
|
||||
|
@ -129,6 +132,11 @@ fn main() -> anyhow::Result<()> {
|
|||
.takes_value(true)
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ignore_broken_rows")
|
||||
.long("ignore-broken-rows")
|
||||
.long_help("Lossy migration methodology if parts of the database are malformed due to e.g. improper manual database surgery. Currently only applies to SQLite.")
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let src_dir = matches.value_of("from_dir").unwrap_or(".");
|
||||
|
@ -155,6 +163,8 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
dbg!(&src_dir, &dst_dir);
|
||||
|
||||
let ignore_broken_rows = matches.is_present("ignore_broken_rows");
|
||||
|
||||
let mut src_db = Database::new(matches.value_of("from").unwrap(), src_dir)?;
|
||||
|
||||
let mut dst_db = Database::new(matches.value_of("to").unwrap(), dst_dir)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue