From 45d5a444eb2a2366cb965e6847345d8b3cdb8c45 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 14 Apr 2026 14:50:47 -0300 Subject: [PATCH] fix: DriveFileRepository compilation errors - Add Debug derive for DriveFileRepository - Clone etag/last_modified for upsert to avoid move errors - Fix max fail_count query to handle nullable integer --- src/drive/drive_files.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/drive/drive_files.rs b/src/drive/drive_files.rs index 2e57ac15..5ad0bb1c 100644 --- a/src/drive/drive_files.rs +++ b/src/drive/drive_files.rs @@ -45,6 +45,12 @@ pub struct DriveFileRepository { pool: DbPool, } +impl std::fmt::Debug for DriveFileRepository { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("DriveFileRepository").finish() + } +} + impl DriveFileRepository { pub fn new(pool: DbPool) -> Self { Self { pool } @@ -77,6 +83,8 @@ impl DriveFileRepository { let mut conn = self.pool.get().map_err(|e| e.to_string())?; let now = Utc::now(); + let etag_clone = etag.clone(); + let last_modified_clone = last_modified.clone(); diesel::insert_into(drive_files::table) .values(( @@ -93,8 +101,8 @@ impl DriveFileRepository { .on_conflict((drive_files::bot_id, drive_files::file_path)) .do_update() .set(( - drive_files::etag.eq(etag), - drive_files::last_modified.eq(last_modified), + drive_files::etag.eq(etag_clone), + drive_files::last_modified.eq(last_modified_clone), drive_files::updated_at.eq(now), )) .execute(&mut conn) @@ -152,7 +160,8 @@ impl DriveFileRepository { drive_files::table .filter(drive_files::bot_id.eq(bot_id)) .select(max(drive_files::fail_count)) - .first(&mut conn) + .first::>(&mut conn) + .unwrap_or(Some(0)) .unwrap_or(0) }