From 3191ff0ff031deb73fb17e6a926c30181a9b58d5 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 20 Nov 2024 10:03:46 +0200 Subject: [PATCH] fix previous auth records cleanup, update error enums --- src/profile/identity/gemini/auth.rs | 11 +++++------ src/profile/identity/gemini/auth/error.rs | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/profile/identity/gemini/auth.rs b/src/profile/identity/gemini/auth.rs index 516b3dbc..0c217b39 100644 --- a/src/profile/identity/gemini/auth.rs +++ b/src/profile/identity/gemini/auth.rs @@ -45,12 +45,10 @@ impl Auth { // Get all records match request match self.database.records(Some(url)) { Ok(records) => { - // Cleanup records match `profile_identity_gemini_id` (unauth) + // Cleanup records match `url` (unauth) for record in records { - if record.profile_identity_gemini_id == profile_identity_gemini_id { - if self.database.delete(record.id).is_err() { - return Err(Error::DatabaseRecordDelete(record.id)); - } + if let Err(reason) = self.database.delete(record.id) { + return Err(Error::DatabaseRecordDelete(record.id, reason)); } } @@ -58,10 +56,11 @@ impl Auth { let profile_identity_gemini_auth_id = match self.database.add(profile_identity_gemini_id, url) { Ok(id) => id, - Err(_) => { + Err(reason) => { return Err(Error::DatabaseRecordCreate( profile_identity_gemini_id, url.to_string(), + reason, )) } }; diff --git a/src/profile/identity/gemini/auth/error.rs b/src/profile/identity/gemini/auth/error.rs index e6b53eec..9368c635 100644 --- a/src/profile/identity/gemini/auth/error.rs +++ b/src/profile/identity/gemini/auth/error.rs @@ -1,8 +1,8 @@ #[derive(Debug)] pub enum Error { DatabaseIndex, - DatabaseRecordCreate(i64, String), - DatabaseRecordDelete(i64), + DatabaseRecordCreate(i64, String, sqlite::Error), + DatabaseRecordDelete(i64, sqlite::Error), DatabaseRecordsRead(String), MemoryIndex(super::memory::Error), }