Rework remove_command()
This commit is contained in:
parent
848fb0b4b4
commit
cd1bb88f20
1 changed files with 16 additions and 14 deletions
|
@ -60,22 +60,24 @@ pub fn remove_command(module: &Module, env: CommandEnv) -> CommandResult {
|
||||||
debug!("Remove by id: {}", id);
|
debug!("Remove by id: {}", id);
|
||||||
|
|
||||||
let parser = Parser::new(JsonHeaderParser::new(None));
|
let parser = Parser::new(JsonHeaderParser::new(None));
|
||||||
env.bk.get_file_by_id(module, &id.into(), &parser).map(|file| {
|
let file = env.bk
|
||||||
debug!("Remove file : {:?}", file);
|
.get_file_by_id(module, &id.into(), &parser)
|
||||||
|
.unwrap_or({
|
||||||
|
info!("No files found");
|
||||||
|
return Ok(())
|
||||||
|
});
|
||||||
|
|
||||||
if let Err(e) = env.bk.remove_file(module, file, checked) {
|
debug!("Remove file: {:?}", file);
|
||||||
debug!("Remove failed");
|
|
||||||
let mut err = ModuleError::new("Removing file failed");
|
if let Err(e) = env.bk.remove_file(module, file, checked) {
|
||||||
err.caused_by = Some(Box::new(e));
|
debug!("Remove failed");
|
||||||
Err(err)
|
let mut err = ModuleError::new("Removing file failed");
|
||||||
} else {
|
err.caused_by = Some(Box::new(e));
|
||||||
info!("Remove worked");
|
Err(err)
|
||||||
Ok(())
|
} else {
|
||||||
}
|
info!("Remove worked");
|
||||||
}).unwrap_or({
|
|
||||||
info!("No files found");
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!("Remove more than one file");
|
debug!("Remove more than one file");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue