diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-05-18 16:22:12 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-05-18 16:22:12 -0400 |
| commit | 491aba6f20d3064fe779fffe265a603591d552ae (patch) | |
| tree | 40ebee7b659fa3a1fa933e805e5983fd4030bdbe /src | |
| parent | 23a9ff86fbea94a6ba6eea28c19139728600ecca (diff) | |
Put the onus of hashing the file on the caller.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 8 |
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); } |