diff --git a/Cargo.lock b/Cargo.lock index e01a5e6..8c12f25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,13 @@ +[[package]] +name = "bakare" +version = "0.1.0" +dependencies = [ + "dir-diff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "1.0.4" @@ -105,16 +115,6 @@ dependencies = [ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustback" -version = "0.1.0" -dependencies = [ - "dir-diff 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rustc-serialize" version = "0.3.24" diff --git a/Cargo.toml b/Cargo.toml index d786f87..74529f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rustback" +name = "bakare" version = "0.1.0" authors = ["Cyryl PÅ‚otnicki "] diff --git a/src/main.rs b/src/main.rs index de476e5..2254de1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,13 +27,9 @@ impl<'a> BackupEngine<'a> { fn backup(&self) -> Result<(), io::Error> { let walker = WalkDir::new(self.source_path); for maybe_entry in walker { - match maybe_entry { - Ok(entry) => { - if entry.path() != self.source_path { - self.process_entry(&entry)?; - } - } - Err(error) => return Err(error.into()), + let entry = maybe_entry?; + if entry.path() != self.source_path { + self.process_entry(&entry)?; } } Ok(()) @@ -44,6 +40,7 @@ impl<'a> BackupEngine<'a> { } fn process_entry(&self, entry: &DirEntry) -> Result<(), io::Error> { + if entry.file_type().is_dir() { fs::create_dir(self.repository_path.join(entry.file_name()))?; } @@ -108,7 +105,7 @@ impl<'a> RestoreEngine<'a> { fn main() {} -mod rustback { +mod bakare { #[cfg(test)] mod should { @@ -162,6 +159,9 @@ mod rustback { Ok(()) } + // TODO: restore latest version by default + // TODO: deduplicate data + fn assert_target_file_contents(target: &Path, filename: &str, expected_contents: &str) -> Result<(), Error> { let restored_path = target.join(filename); let mut actual_contents = String::new();