summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2020-05-18 16:22:12 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2020-05-18 16:22:12 -0400
commit491aba6f20d3064fe779fffe265a603591d552ae (patch)
tree40ebee7b659fa3a1fa933e805e5983fd4030bdbe
parent23a9ff86fbea94a6ba6eea28c19139728600ecca (diff)
Put the onus of hashing the file on the caller.
-rw-r--r--src/main.rs8
1 files changed, 4 insertions, 4 deletions
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<i64> {
+ fn import_image(&self, path: &Path, hash: &str) -> Result<i64> {
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);
}