From f7592fdf3484b31ac7365a97fc9070dee0caa533 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 8 May 2024 16:31:45 -0400 Subject: [PATCH] Use select exists again. --- crates/db_schema/src/impls/images.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/db_schema/src/impls/images.rs b/crates/db_schema/src/impls/images.rs index d11b4ec05..0de734cb2 100644 --- a/crates/db_schema/src/impls/images.rs +++ b/crates/db_schema/src/impls/images.rs @@ -84,12 +84,13 @@ impl RemoteImage { pub async fn validate(pool: &mut DbPool<'_>, link_: DbUrl) -> Result<(), Error> { let conn = &mut get_conn(pool).await?; - let res = remote_image::table - .find(link_) - .first::(conn) - .await - .optional()?; - if res.is_some() { + + let exists = select(exists( + remote_image::table.filter(remote_image::link.eq(link_)), + )) + .get_result::(conn) + .await?; + if exists { Ok(()) } else { Err(NotFound)