Ensure we dont crash if there are no files found

This commit is contained in:
Matthias Beyer 2015-12-04 23:01:37 +01:00
parent fd3d2ec8dc
commit 87d5852986

View file

@ -60,7 +60,7 @@ pub fn remove_command(module: &Module, env: CommandEnv) -> CommandResult {
debug!("Remove by id: {}", id);
let parser = Parser::new(JsonHeaderParser::new(None));
let file = env.bk.get_file_by_id(module, &id.into(), &parser).unwrap();
env.bk.get_file_by_id(module, &id.into(), &parser).map(|file| {
debug!("Remove file : {:?}", file);
if let Err(e) = env.bk.remove_file(module, file, checked) {
@ -69,9 +69,13 @@ pub fn remove_command(module: &Module, env: CommandEnv) -> CommandResult {
err.caused_by = Some(Box::new(e));
Err(err)
} else {
debug!("Remove worked");
info!("Remove worked");
Ok(())
}
}).unwrap_or({
info!("No files found");
Ok(())
})
} else {
debug!("Remove more than one file");