From 491aba6f20d3064fe779fffe265a603591d552ae Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Mon, 18 May 2020 16:22:12 -0400 Subject: Put the onus of hashing the file on the caller. --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b5c0d93..54ab708 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,12 +74,11 @@ impl TagBase { } /// Insert the image at `path` into the data. - fn import_image(&self, path: &Path) -> Result { + fn import_image(&self, path: &Path, hash: &str) -> Result { if path.is_dir() { bail!("`path` does not name a file."); } - let hash = hash_file(path)?; let file_name = path .file_name() .and_then(|os| os.to_str()) @@ -160,7 +159,8 @@ mod tests { fn main() { let tb = TagBase::new("/tmp/test.db").unwrap(); - tb.import_image(Path::new("/home/jakob/Sync/06fc9ae71549eb4d.jpeg")) - .unwrap(); + let path = Path::new("/home/jakob/Sync/06fc9ae71549eb4d.jpeg"); + let hash = hash_file(path).unwrap(); + tb.import_image(path, &hash).unwrap(); println!("{:?}", tb); } -- cgit v1.3