Merge pull request #375 from matthiasbeyer/imag-store/zero-warnings

Imag store/zero warnings
This commit is contained in:
Matthias Beyer 2016-04-21 15:07:54 +02:00
commit 4d27958699
6 changed files with 21 additions and 13 deletions

View file

@ -32,7 +32,7 @@ pub fn create(rt: &Runtime) {
let path = scmd.value_of("path").or_else(|| scmd.value_of("id")); let path = scmd.value_of("path").or_else(|| scmd.value_of("id"));
if path.is_none() { if path.is_none() {
warn!("No ID / Path provided. Exiting now"); warn!("No ID / Path provided. Exiting now");
write!(stderr(), "No ID / Path provided. Exiting now"); write!(stderr(), "No ID / Path provided. Exiting now").ok();
exit(1); exit(1);
} }
@ -101,14 +101,15 @@ fn create_from_source(rt: &Runtime, matches: &ArgMatches, path: &PathBuf) -> Res
debug!("Content with len = {}", content.len()); debug!("Content with len = {}", content.len());
Entry::from_str(path.clone(), &content[..]) Entry::from_str(path.clone(), &content[..])
.map(|mut new_e| { .and_then(|new_e| {
rt.store() let r = rt.store()
.create(path.clone()) .create(path.clone())
.map(|mut old_e| { .map(|mut old_e| {
*old_e.deref_mut() = new_e; *old_e.deref_mut() = new_e;
}); });
debug!("Entry build"); debug!("Entry build");
r
}) })
.map_err(|serr| StoreError::new(StoreErrorKind::BackendError, Some(Box::new(serr)))) .map_err(|serr| StoreError::new(StoreErrorKind::BackendError, Some(Box::new(serr))))
} }
@ -144,7 +145,7 @@ fn string_from_raw_src(raw_src: &str) -> String {
debug!("Read {:?} bytes", res); debug!("Read {:?} bytes", res);
} else { } else {
debug!("Reading entry from file at {:?}", raw_src); debug!("Reading entry from file at {:?}", raw_src);
OpenOptions::new() let _ = OpenOptions::new()
.read(true) .read(true)
.write(false) .write(false)
.create(false) .create(false)

View file

@ -1,5 +1,3 @@
use std::path::PathBuf;
use libimagstore::storeid::build_entry_path; use libimagstore::storeid::build_entry_path;
use libimagrt::runtime::Runtime; use libimagrt::runtime::Runtime;
use libimagutil::trace::trace_error; use libimagutil::trace::trace_error;

View file

@ -1,3 +1,18 @@
#![deny(
non_camel_case_types,
non_snake_case,
path_statements,
trivial_numeric_casts,
unstable_features,
unused_allocation,
unused_import_braces,
unused_imports,
unused_must_use,
unused_mut,
unused_qualifications,
while_true,
)]
extern crate clap; extern crate clap;
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate semver; extern crate semver;

View file

@ -1,6 +1,4 @@
use std::path::PathBuf;
use std::ops::Deref; use std::ops::Deref;
use std::fmt::Display;
use std::process::exit; use std::process::exit;
use clap::ArgMatches; use clap::ArgMatches;

View file

@ -1,4 +1,3 @@
use std::path::PathBuf;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::process::exit; use std::process::exit;

View file

@ -1,16 +1,13 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::path::PathBuf;
use std::str::Split; use std::str::Split;
use clap::ArgMatches; use clap::ArgMatches;
use semver::Version;
use toml::Value; use toml::Value;
use libimagstore::store::EntryHeader; use libimagstore::store::EntryHeader;
use libimagrt::runtime::Runtime;
use libimagutil::key_value_split::IntoKeyValue; use libimagutil::key_value_split::IntoKeyValue;
pub fn build_toml_header(matches: &ArgMatches, mut header: EntryHeader) -> EntryHeader { pub fn build_toml_header(matches: &ArgMatches, header: EntryHeader) -> EntryHeader {
debug!("Building header from cli spec"); debug!("Building header from cli spec");
if let Some(headerspecs) = matches.values_of("header") { if let Some(headerspecs) = matches.values_of("header") {
let mut main = header.into(); let mut main = header.into();