Rework remove_command()

This commit is contained in:
Matthias Beyer 2015-12-04 23:19:18 +01:00
parent 848fb0b4b4
commit cd1bb88f20

View file

@ -60,8 +60,14 @@ 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(())
});
debug!("Remove file: {:?}", file);
if let Err(e) = env.bk.remove_file(module, file, checked) { if let Err(e) = env.bk.remove_file(module, file, checked) {
debug!("Remove failed"); debug!("Remove failed");
@ -72,10 +78,6 @@ pub fn remove_command(module: &Module, env: CommandEnv) -> CommandResult {
info!("Remove worked"); info!("Remove worked");
Ok(()) Ok(())
} }
}).unwrap_or({
info!("No files found");
Ok(())
})
} else { } else {
debug!("Remove more than one file"); debug!("Remove more than one file");