Skip to content

web search done right

failed to move webgraph when done: directory not empty

Mikkel Denker3a8dab019ee7
diff --git a/core/src/entrypoint/webgraph.rs b/core/src/entrypoint/webgraph.rs
index 5434c2db..4c55790d 100644
--- a/core/src/entrypoint/webgraph.rs
+++ b/core/src/entrypoint/webgraph.rs
@@ -26,7 +26,7 @@ use crate::{
};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
-use std::{path::Path, sync::Arc};
+use std::{fs, path::Path, sync::Arc};
use tokio::pin;
use tracing::{info, trace};
@@ -215,11 +215,11 @@ impl Webgraph {
let mut graph = graphs.pop().unwrap();
for other_graph in graphs {
+ let other_path = other_graph.path.clone();
graph.merge(other_graph);
+ fs::remove_dir_all(other_path)?;
}
- graph.move_to(&parent_path);
-
Ok(())
}
}
diff --git a/core/src/webgraph/mod.rs b/core/src/webgraph/mod.rs
index c008f456..e65b3df3 100644
--- a/core/src/webgraph/mod.rs
+++ b/core/src/webgraph/mod.rs
@@ -626,24 +626,6 @@ impl Webgraph {
}
}
}
-
- pub fn move_to<P: AsRef<Path>>(&mut self, new_path: P) {
- let path = Path::new(&self.path);
- let new_path = new_path.as_ref();
-
- if path == new_path {
- return;
- }
-
- fs::rename(path, new_path).unwrap();
-
- let path = Path::new(&self.path);
- if path.exists() {
- fs::remove_dir_all(path).unwrap();
- }
-
- self.path = new_path.as_os_str().to_str().unwrap().to_string();
- }
}
impl From<FrozenWebgraph> for Webgraph {