use crate::config::datastore;
use crate::backup::*;
+use crate::server::WorkerTask;
mod pxar;
mod upload;
)
}
-// this is just a test for mutability/mutex handling - will remove later
fn start_garbage_collection(
param: Value,
_info: &ApiMethod,
- _rpcenv: &mut RpcEnvironment,
+ 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()?;
+ let to_stdout = if rpcenv.env_type() == RpcEnvironmentType::CLI { true } else { false };
- Ok(json!(null))
+ let upid_str = WorkerTask::new_thread(
+ "garbage_collection", Some(store.clone()), "root@pam", to_stdout, move |worker|
+ {
+ worker.log(format!("starting garbage collection on store {}", store));
+ datastore.garbage_collection()
+ })?;
+
+ Ok(json!(upid_str))
}
pub fn api_method_start_garbage_collection() -> ApiMethod {