src/api2/admin/datastore.rs: start GC in a separate thread

This commit is contained in:
Dietmar Maurer 2019-04-01 12:02:46 +02:00
parent ad281d1bd9
commit 3e6a7deeaa

View File

@ -288,13 +288,17 @@ fn start_garbage_collection(
_rpcenv: &mut RpcEnvironment,
) -> Result<Value, Error> {
let store = param["store"].as_str().unwrap();
let store = param["store"].as_str().unwrap().to_string();
let datastore = DataStore::lookup_datastore(store)?;
let datastore = DataStore::lookup_datastore(&store)?;
println!("Starting garbage collection on store {}", store);
datastore.garbage_collection()?;
std::thread::spawn(move || {
if let Err(err) = datastore.garbage_collection() {
println!("Garbage collection error on store {} - {}", store, err);
}
});
Ok(json!(null))
}