diff options
| author | Joris Guyonvarch | 2026-03-21 22:02:10 +0100 |
|---|---|---|
| committer | Joris Guyonvarch | 2026-03-21 22:02:10 +0100 |
| commit | 44cf1913ea1433b99154fb46f5761ac8b280908b (patch) | |
| tree | 5dd19b4b812c7419bcb040286bcf400024768f9a /src/db | |
| parent | cf406c5c9c38a24549c9fdd7e807632aef051766 (diff) | |
Upgrade dependencies
Diffstat (limited to 'src/db')
| -rw-r--r-- | src/db/files.rs | 14 | ||||
| -rw-r--r-- | src/db/mod.rs | 12 | ||||
| -rw-r--r-- | src/db/utils.rs | 3 |
3 files changed, 10 insertions, 19 deletions
diff --git a/src/db/files.rs b/src/db/files.rs index 995a2ed..f9b669d 100644 --- a/src/db/files.rs +++ b/src/db/files.rs @@ -1,7 +1,6 @@ use chrono::{DateTime, Local}; use tokio_rusqlite::{named_params, Connection, Result}; -use crate::db::utils; use crate::model::{decode_datetime, encode_datetime, File}; pub async fn insert(conn: &Connection, file: File) -> Result<()> { @@ -20,7 +19,6 @@ pub async fn insert(conn: &Connection, file: File) -> Result<()> { ":content_length": file.content_length ], ) - .map_err(tokio_rusqlite::Error::Rusqlite) }) .await .map(|_| ()) @@ -54,12 +52,16 @@ pub async fn get(conn: &Connection, file_id: impl Into<String>) -> Result<Option expires_at, content_length, })), - _ => Err(utils::rusqlite_other_error(format!( - "Error decoding datetime: {expires_at}" - ))), + _ => { + log::error!("Error decoding datetime: {expires_at}"); + Ok(None) + } } } - Some(_) => Err(utils::rusqlite_other_error("Error reading file in DB")), + Some(_) => { + log::error!("Error reading file in DB"); + Ok(None) + }, None => Ok(None), } }) diff --git a/src/db/mod.rs b/src/db/mod.rs index 37769d2..c3c2258 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -3,7 +3,6 @@ use rusqlite_migration::{Migrations, M}; use tokio_rusqlite::Connection; pub mod files; -mod utils; pub async fn init(path: &str) -> Result<Connection> { let connection = Connection::open(path) @@ -23,11 +22,7 @@ async fn apply_migrations(conn: &Connection) -> Result<()> { ]); Ok(conn - .call(move |conn| { - migrations - .to_latest(conn) - .map_err(|migration_err| tokio_rusqlite::Error::Other(Box::new(migration_err))) - }) + .call(move |conn| migrations .to_latest(conn)) .await?) } @@ -39,9 +34,6 @@ async fn set_pragma( let key = key.into(); let value = value.into(); Ok(conn - .call(move |conn| { - conn.pragma_update(None, &key, &value) - .map_err(tokio_rusqlite::Error::Rusqlite) - }) + .call(move |conn| conn.pragma_update(None, &key, &value)) .await?) } diff --git a/src/db/utils.rs b/src/db/utils.rs deleted file mode 100644 index 0b3e029..0000000 --- a/src/db/utils.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn rusqlite_other_error(msg: impl Into<String>) -> tokio_rusqlite::Error { - tokio_rusqlite::Error::Other(msg.into().into()) -} |
