better verbosity
This commit is contained in:
parent
34c12508f5
commit
14490bbe78
6 changed files with 25 additions and 7 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -25,6 +25,7 @@ name = "bakare"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_cbor 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_cbor 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -147,6 +148,11 @@ name = "half"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hex"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
|
@ -490,6 +496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
||||||
"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872"
|
"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872"
|
||||||
"checksum half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9353c2a89d550b58fa0061d8ed8d002a7d8cdf2494eb0e432859bd3a9e543836"
|
"checksum half 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9353c2a89d550b58fa0061d8ed8d002a7d8cdf2494eb0e432859bd3a9e543836"
|
||||||
|
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
||||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
|
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
|
||||||
"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||||
|
|
|
@ -13,3 +13,4 @@ serde_cbor = "0.10"
|
||||||
tempfile = "3.1"
|
tempfile = "3.1"
|
||||||
walkdir = "2.2"
|
walkdir = "2.2"
|
||||||
sha2 = "0.8"
|
sha2 = "0.8"
|
||||||
|
hex = "0.3"
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl Index {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remember(&mut self, item: RepositoryItem) {
|
pub fn remember(&mut self, item: RepositoryItem) {
|
||||||
println!("remembering {:#?}", item);
|
println!("remembering {}", item);
|
||||||
self.items.push(item.into());
|
self.items.push(item.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::repository_item::RepositoryItem;
|
||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
use sha2::Sha512;
|
use sha2::Sha512;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, Read};
|
use std::io::BufReader;
|
||||||
|
|
||||||
/// represents a place where backup is stored an can be restored from.
|
/// represents a place where backup is stored an can be restored from.
|
||||||
/// right now only on-disk directory storage is supported
|
/// right now only on-disk directory storage is supported
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use crate::error::BakareError;
|
use crate::error::BakareError;
|
||||||
use sha2::digest::DynDigest;
|
use std::fmt::{Display, Formatter};
|
||||||
use sha2::{Digest, Sha512};
|
|
||||||
use std::fs;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::{fmt, fs};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialOrd, PartialEq, Ord, Eq)]
|
#[derive(Clone, Debug, PartialOrd, PartialEq, Ord, Eq)]
|
||||||
pub struct RepositoryItem {
|
pub struct RepositoryItem {
|
||||||
|
@ -53,3 +52,14 @@ impl RepositoryItem {
|
||||||
self.version.clone()
|
self.version.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Display for RepositoryItem {
|
||||||
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"'{}' : {}",
|
||||||
|
self.original_source_path().to_string_lossy(),
|
||||||
|
hex::encode(self.version())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ fn restore_older_version_of_file() -> Result<(), BakareError> {
|
||||||
let item = reading_repository.item_by_source_path(&file_path)?;
|
let item = reading_repository.item_by_source_path(&file_path)?;
|
||||||
assert!(item.is_some());
|
assert!(item.is_some());
|
||||||
let item = item.unwrap();
|
let item = item.unwrap();
|
||||||
let old_version = item.version();
|
let _old_version = item.version();
|
||||||
|
|
||||||
{
|
{
|
||||||
let new_contents = "totally new contents";
|
let new_contents = "totally new contents";
|
||||||
|
@ -86,7 +86,7 @@ fn restore_older_version_of_file() -> Result<(), BakareError> {
|
||||||
|
|
||||||
let restore_repository = Repository::open(repository_path.as_path())?;
|
let restore_repository = Repository::open(repository_path.as_path())?;
|
||||||
let restore_target = tempdir()?;
|
let restore_target = tempdir()?;
|
||||||
let restore_engine = restore::Engine::new(&restore_repository, &restore_target.path())?;
|
let _restore_engine = restore::Engine::new(&restore_repository, &restore_target.path())?;
|
||||||
//restore_engine.restore_as_of_version(&item, old_version)?;
|
//restore_engine.restore_as_of_version(&item, old_version)?;
|
||||||
|
|
||||||
assert_target_file_contents(restore_target.path(), relative_path_text, old_contents)
|
assert_target_file_contents(restore_target.path(), relative_path_text, old_contents)
|
||||||
|
|
Loading…
Reference in a new issue