From 5102eb8d425da6d925c745856b914961076de7aa Mon Sep 17 00:00:00 2001 From: "Jakob L. Kreuze" Date: Mon, 18 May 2020 11:24:03 -0400 Subject: Have `import_image` return the image's ID. --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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 { 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> = 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()) } } -- cgit v1.3