diff --git a/src/lib.rs b/src/lib.rs index 200423a..13f1b8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ // rustfmt -#![deny(fat_ptr_transmutes, -trivial_numeric_casts, unsafe_code, +#![deny(trivial_numeric_casts, unsafe_code, unstable_features, unused_extern_crates, unused_import_braces, unused_qualifications, variant_size_differences diff --git a/src/schema.rs b/src/schema.rs index 248e14e..af3e942 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -139,7 +139,7 @@ impl SymbolRunner for NonRepeatingSymbolRunner { for resource in resources { if !done.contains(&resource) { has_to_run = true; - done.insert(resource.clone()); + assert!(done.insert(resource.clone())); } } if !has_to_run { diff --git a/src/symbols/acme/account_key.rs b/src/symbols/acme/account_key.rs index 4c94797..32f3fb5 100644 --- a/src/symbols/acme/account_key.rs +++ b/src/symbols/acme/account_key.rs @@ -1,4 +1,4 @@ -use std::borrow::{Borrow, Cow}; +use std::borrow::Cow; use std::error::Error; use std::fmt; use std::path::Path; diff --git a/src/symbols/acme/user.rs b/src/symbols/acme/user.rs index f7fa7ae..6181907 100644 --- a/src/symbols/acme/user.rs +++ b/src/symbols/acme/user.rs @@ -10,7 +10,6 @@ use symbols::{Action, OwnedSymbolAction, SymbolAction, SymbolRunner, Symbol}; use symbols::acme::AcmeAccountKey; use symbols::dir::Dir; use symbols::file::File; -use symbols::hook::Hook; use symbols::list::List; use symbols::owner::Owner; diff --git a/src/symbols/user.rs b/src/symbols/user.rs index 15fc7c0..0d4888c 100644 --- a/src/symbols/user.rs +++ b/src/symbols/user.rs @@ -1,7 +1,6 @@ use std::borrow::Cow; use std::error::Error; use std::fmt; -use std::io::Error as IoError; use command_runner::CommandRunner; use resources::Resource; diff --git a/src/symbols/wordpress/plugin.rs b/src/symbols/wordpress/plugin.rs index 97beb5b..b1c8a51 100644 --- a/src/symbols/wordpress/plugin.rs +++ b/src/symbols/wordpress/plugin.rs @@ -2,7 +2,8 @@ use regex::Regex; use std::error::Error; use std::fmt; use std::fs::File as FsFile; -use std::io::Read; +use std::io; +use std::io::{BufRead, BufReader}; use std::ops::Deref; use std::path::{Path, PathBuf}; @@ -36,17 +37,29 @@ impl<'a, C, R> Symbol for WordpressPlugin<'a, C, R> where C: Deref + return Ok(false); } let path = self.get_path().join(self.name.to_string() + ".php"); - let mut file = try!(FsFile::open(path)); - let mut file_content = String::new(); - try!(file.read_to_string(&mut file_content)); let mut version = String::new(); let mut plugin_uri = String::new(); - let regex = try!(Regex::new("(?m)^(Plugin URI|Version): (.+)$")); - for matches in regex.captures_iter(&file_content) { - if &matches[1] == "Plugin URI" { - plugin_uri = matches[2].to_string(); - } else { - version = matches[2].to_string(); + match FsFile::open(path) { + Err(e) => { + // Check if file exists + return if e.kind() == io::ErrorKind::NotFound { + Ok(false) + } else { + Err(Box::new(e)) + }; + }, + Ok(file) => { + let mut reader = BufReader::new(file); + let regex = Regex::new("(?m)^(Plugin URI|Version): (.+)$")?; + for content in reader.lines() { + for matches in regex.captures_iter(&(content?)) { + if &matches[1] == "Plugin URI" { + plugin_uri = matches[2].to_string(); + } else { + version = matches[2].to_string(); + } + } + } } } let upstream = try!(self.command_runner.get_output("curl", &["--form", &format!(r###"plugins={{"plugins":{{"{0}/{0}.php":{{"Version":"{1}", "PluginURI":"{2}"}}}}}}"###, self.name, version, plugin_uri), "https://api.wordpress.org/plugins/update-check/1.1/"])); diff --git a/src/symbols/wordpress/translation.rs b/src/symbols/wordpress/translation.rs index 930c450..0fb7c01 100644 --- a/src/symbols/wordpress/translation.rs +++ b/src/symbols/wordpress/translation.rs @@ -4,7 +4,7 @@ use std::error::Error; use std::fmt; use std::fs::File as FsFile; use std::io; -use std::io::Read; +use std::io::{BufRead, BufReader}; use std::path::Path; use command_runner::CommandRunner; @@ -52,20 +52,24 @@ impl<'a, C, D, R> Symbol for WordpressTranslation<'a, C, D, R> where C: AsRef { + // Check if file exists + return if e.kind() == io::ErrorKind::NotFound { + Ok(false) + } else { + Err(Box::new(e)) + }; + }, + Ok(mut file) => if target.ends_with(".po") { + let mut reader = BufReader::new(file); + for content in reader.lines() { + if let Some(match_result) = match_date.captures(&try!(content)) { + newest = max(newest, match_result[1].to_string()); + break; + } + } + } } } let upstream = try!(self.command_runner.get_output("curl", &[&format!("https://api.wordpress.org/core/version-check/1.7/?version={}&locale={}", self.version, self.locale)]));