Merge pull request #617 from matthiasbeyer/imag-store/refactor-unwraps

Imag store/refactor unwraps
This commit is contained in:
Matthias Beyer 2016-08-03 13:56:45 +02:00 committed by GitHub
commit b6ce57418e
5 changed files with 16 additions and 25 deletions

View file

@ -36,11 +36,10 @@ pub fn create(rt: &Runtime) {
exit(1); exit(1);
} }
let path = build_entry_path(rt.store(), path.unwrap()); let path = match build_entry_path(rt.store(), path.unwrap()) {
if path.is_err() { Err(e) => trace_error_exit(&e, 1),
trace_error_exit(&path.unwrap_err(), 1); Ok(p) => p,
} };
let path = path.unwrap();
debug!("path = {:?}", path); debug!("path = {:?}", path);
if scmd.subcommand_matches("entry").is_some() { if scmd.subcommand_matches("entry").is_some() {

View file

@ -10,11 +10,8 @@ pub fn delete(rt: &Runtime) {
.map(|sub| { .map(|sub| {
sub.value_of("id") sub.value_of("id")
.map(|id| { .map(|id| {
let path = build_entry_path(rt.store(), id); let path = try!(build_entry_path(rt.store(), id)
if path.is_err() { .map_err(|e| trace_error_exit(&e, 1)));
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
debug!("Deleting file at {:?}", id); debug!("Deleting file at {:?}", id);
rt.store() rt.store()

View file

@ -10,11 +10,10 @@ pub fn get(rt: &Runtime) {
.map(|scmd| { .map(|scmd| {
scmd.value_of("id") scmd.value_of("id")
.map(|id| { .map(|id| {
let path = build_entry_path(rt.store(), id); let path = match build_entry_path(rt.store(), id) {
if path.is_err() { Err(e) => trace_error_exit(&e, 1),
trace_error_exit(&path.unwrap_err(), 1); Ok(p) => p,
} };
let path = path.unwrap();
debug!("path = {:?}", path); debug!("path = {:?}", path);
match rt.store().get(path) { match rt.store().get(path) {

View file

@ -12,11 +12,8 @@ pub fn retrieve(rt: &Runtime) {
.map(|scmd| { .map(|scmd| {
scmd.value_of("id") scmd.value_of("id")
.map(|id| { .map(|id| {
let path = build_entry_path(rt.store(), id); let path = try!(build_entry_path(rt.store(), id)
if path.is_err() { .map_err(|e| trace_error_exit(&e, 1)));
trace_error_exit(&path.unwrap_err(), 1);
}
let path = path.unwrap();
debug!("path = {:?}", path); debug!("path = {:?}", path);
rt.store() rt.store()

View file

@ -12,11 +12,10 @@ pub fn update(rt: &Runtime) {
.map(|scmd| { .map(|scmd| {
scmd.value_of("id") scmd.value_of("id")
.map(|id| { .map(|id| {
let path = build_entry_path(rt.store(), id); let path = match build_entry_path(rt.store(), id) {
if path.is_err() { Err(e) => trace_error_exit(&e, 1),
trace_error_exit(&path.unwrap_err(), 1); Ok(p) => p,
} };
let path = path.unwrap();
rt.store() rt.store()
.retrieve(path) .retrieve(path)