use anyhow::Result;
use std::path::Path;
use super::kuzu_import::{handle_import_kuzu, KuzuImportArgs, DEFAULT_MAX_DEPTH};
pub fn handle_kuzu_data_migrate(
from: &Path,
palace_name: &str,
dry_run: bool,
limit: Option<usize>,
) -> Result<()> {
eprintln!(
"warning: `migrate kuzu-data` is deprecated and will be removed; use \
`trusty-memory import kuzu --from <.kuzu-memory dir> [--palace <name>]`"
);
if limit.is_some() {
anyhow::bail!(
"--limit is not supported by `import kuzu`; drop it, or preview the import \
with --dry-run"
);
}
let args = deprecated_args(from, palace_name, dry_run);
std::thread::scope(|scope| {
scope
.spawn(|| {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.enable_all()
.build()?
.block_on(handle_import_kuzu(args))
})
.join()
.map_err(|_| anyhow::anyhow!("kuzu import thread panicked"))?
})
}
pub(crate) fn deprecated_args(from: &Path, palace_name: &str, dry_run: bool) -> KuzuImportArgs {
KuzuImportArgs {
from: Some(from.to_path_buf()),
palace: Some(palace_name.to_string()),
dry_run,
max_depth: DEFAULT_MAX_DEPTH,
..KuzuImportArgs::default()
}
}