Cargo fix
This commit is contained in:
parent
5505c09db4
commit
9bab810b91
38 changed files with 235 additions and 235 deletions
|
|
@ -16,7 +16,7 @@ impl<'a, C: CommandRunner> PostgreSQLDatabase<'a, C> {
|
|||
PostgreSQLDatabase { name, seed_file, command_runner }
|
||||
}
|
||||
|
||||
fn run_sql(&self, sql: &str) -> Result<String, Box<Error>> {
|
||||
fn run_sql(&self, sql: &str) -> Result<String, Box<dyn Error>> {
|
||||
let b = try!(self.command_runner.get_output("su", &["-", "postgres", "-c", &format!("psql -t -c \"{}\"", sql)]));
|
||||
Ok(try!(String::from_utf8(b)))
|
||||
}
|
||||
|
|
@ -29,21 +29,21 @@ impl<'a, C: CommandRunner> fmt::Display for PostgreSQLDatabase<'a, C> {
|
|||
}
|
||||
|
||||
impl<'a, C: CommandRunner> Symbol for PostgreSQLDatabase<'a, C> {
|
||||
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
||||
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
||||
Ok(try!(self.run_sql(&format!("SELECT datname FROM pg_database WHERE datname LIKE '{}'", self.name))).trim() == self.name)
|
||||
}
|
||||
|
||||
fn execute(&self) -> Result<(), Box<Error>> {
|
||||
fn execute(&self) -> Result<(), Box<dyn Error>> {
|
||||
self.command_runner.run_successfully("su", &["-", "postgres", "-c", &format!("createuser {}", self.name)])?;
|
||||
self.command_runner.run_successfully("su", &["-", "postgres", "-c", &format!("createdb -E UTF8 -T template0 -O {} {0}", self.name)])?;
|
||||
self.command_runner.run_successfully("su", &["-", "postgres", "-c", &format!("psql '{}' < {}", self.name, self.seed_file)])
|
||||
}
|
||||
|
||||
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
|
||||
fn as_action<'b>(&'b self, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> {
|
||||
Box::new(SymbolAction::new(runner, self))
|
||||
}
|
||||
|
||||
fn into_action<'b>(self: Box<Self>, runner: &'b SymbolRunner) -> Box<Action + 'b> where Self: 'b {
|
||||
fn into_action<'b>(self: Box<Self>, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> where Self: 'b {
|
||||
Box::new(OwnedSymbolAction::new(runner, *self))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> DatabaseDump<'a, N, C, S>
|
|||
DatabaseDump { db_name, storage, command_runner }
|
||||
}
|
||||
|
||||
fn run_sql(&self, sql: &str) -> Result<String, Box<Error>> {
|
||||
fn run_sql(&self, sql: &str) -> Result<String, Box<dyn Error>> {
|
||||
let b = try!(self.command_runner.get_output("mariadb", &["--skip-column-names", "-B", "-e", sql]));
|
||||
Ok(try!(String::from_utf8(b)))
|
||||
}
|
||||
|
|
@ -30,22 +30,22 @@ impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> fmt::Display for DatabaseD
|
|||
}
|
||||
|
||||
impl<'a, N: AsRef<str>, C: CommandRunner, S: Storage> Symbol for DatabaseDump<'a, N, C, S> {
|
||||
fn target_reached(&self) -> Result<bool, Box<Error>> {
|
||||
fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
||||
let dump_date = try!(self.storage.recent_date());
|
||||
let modified_date = try!(self.run_sql(&format!("select UNIX_TIMESTAMP(MAX(UPDATE_TIME)) from information_schema.tables WHERE table_schema = '{}'", self.db_name.as_ref())));
|
||||
if modified_date.trim_right() == "NULL" { return Ok(false); }
|
||||
Ok(try!(u64::from_str(modified_date.trim_right())) <= dump_date)
|
||||
if modified_date.trim_end() == "NULL" { return Ok(false); }
|
||||
Ok(try!(u64::from_str(modified_date.trim_end())) <= dump_date)
|
||||
}
|
||||
|
||||
fn execute(&self) -> Result<(), Box<Error>> {
|
||||
fn execute(&self) -> Result<(), Box<dyn Error>> {
|
||||
self.command_runner.run_successfully("sh", &["-c", &format!("mysqldump '{}' > {}", self.db_name.as_ref(), self.storage.write_filename())])
|
||||
}
|
||||
|
||||
fn as_action<'b>(&'b self, runner: &'b SymbolRunner) -> Box<Action + 'b> {
|
||||
fn as_action<'b>(&'b self, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> {
|
||||
Box::new(SymbolAction::new(runner, self))
|
||||
}
|
||||
|
||||
fn into_action<'b>(self: Box<Self>, runner: &'b SymbolRunner) -> Box<Action + 'b> where Self: 'b {
|
||||
fn into_action<'b>(self: Box<Self>, runner: &'b dyn SymbolRunner) -> Box<dyn Action + 'b> where Self: 'b {
|
||||
Box::new(OwnedSymbolAction::new(runner, *self))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue