From 057dcb330814c16b7b1460fcbea4c938d3c295c5 Mon Sep 17 00:00:00 2001 From: NexVeridian Date: Mon, 26 Aug 2024 00:03:45 -0700 Subject: [PATCH] fix tokio::fs --- Cargo.toml | 2 +- src/utils.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9441e87..790faac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" surrealdb-alpha = { version = "2.0.9", features = ["protocol-ws", "kv-mem"] } -tokio = { version = "1.39", features = ["time"] } +tokio = { version = "1.39", features = ["fs", "time"] } futures = "0.3" wikidata = "1.1" bzip2 = { version = "0.4", features = ["tokio"] } diff --git a/src/utils.rs b/src/utils.rs index 8bc9856..cce3712 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -184,11 +184,12 @@ pub async fn create_db_entities_bulk_filter( .map(char::from) .collect(); - db_mem - .export(format!("../data/temp/{}.surql", file_name)) - .await?; - db.import(format!("../data/temp{}.surql", file_name)) - .await?; + let file_path = format!("data/temp/{}.surql", file_name); + + db_mem.export(&file_path).await?; + db.import(&file_path).await?; + + tokio::fs::remove_file(&file_path).await?; if let Some(ref p) = pb { p.inc(batch_size as u64)