summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2020-05-18 11:24:03 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2020-05-18 11:24:49 -0400
commit5102eb8d425da6d925c745856b914961076de7aa (patch)
treee43e6d026acfb76fd03eedcc77126147da8ca173 /src/main.rs
parentebb69ed108bbb530e16806974291cd3ce265e990 (diff)
Have `import_image` return the image's ID.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 94e9804..ed0965c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -51,7 +51,7 @@ impl TagBase {
}
/// Insert the image at `path` into the data.
- fn import_image(&self, path: &Path) -> Result<()> {
+ fn import_image(&self, path: &Path) -> Result<i32> {
if path.is_dir() {
return Err(anyhow!("`path` does not name a file."));
}
@@ -74,7 +74,12 @@ impl TagBase {
params![hash, file_name, parent_directory],
)?;
- Ok(())
+ let id: Vec<std::result::Result<i32, rusqlite::Error>> = self
+ .conn
+ .prepare("SELECT id FROM images WHERE blake2 = ?;")?
+ .query_and_then(params![hash], |row| row.get(0))?
+ .collect();
+ Ok(*id[0].as_ref().unwrap())
}
}