From ed1b728fdb8304bd2f7e01e0b5e92550a69b263b Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 6 May 2024 09:39:25 -0400 Subject: [PATCH] Cleaning up validate. --- crates/db_schema/src/impls/images.rs | 17 ++++++++--------- docker/federation/docker-compose.yml | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/db_schema/src/impls/images.rs b/crates/db_schema/src/impls/images.rs index 8cc2aa795..c699329db 100644 --- a/crates/db_schema/src/impls/images.rs +++ b/crates/db_schema/src/impls/images.rs @@ -12,12 +12,11 @@ use crate::{ utils::{get_conn, DbPool}, }; use diesel::{ - dsl::exists, insert_into, result::Error, - select, ExpressionMethods, NotFound, + OptionalExtension, QueryDsl, }; use diesel_async::RunQueryDsl; @@ -60,13 +59,12 @@ impl RemoteImage { pub async fn validate(pool: &mut DbPool<'_>, link_: DbUrl) -> Result<(), Error> { let conn = &mut get_conn(pool).await?; - - let exists = select(exists( - remote_image::table.filter(remote_image::link.eq(link_)), - )) - .get_result::(conn) - .await?; - if exists { + let res = remote_image::table + .find(link_) + .first::(conn) + .await + .optional()?; + if res.is_some() { Ok(()) } else { Err(NotFound) @@ -79,6 +77,7 @@ impl ImageDetails { let conn = &mut get_conn(pool).await?; insert_into(image_details::table) .values(form) + .on_conflict_do_nothing() .get_result::(conn) .await } diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 8dd70f3bc..ac4ef4649 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -49,7 +49,7 @@ services: pictrs: restart: always - image: asonix/pictrs:0.5.0-rc.2 + image: asonix/pictrs:0.5.13 user: 991:991 volumes: - ./volumes/pictrs_alpha:/mnt:Z