Use select exists again.

This commit is contained in:
Dessalines 2024-05-08 16:31:45 -04:00
parent 8a0b7c05d3
commit f7592fdf34

View file

@ -84,12 +84,13 @@ impl RemoteImage {
pub async fn validate(pool: &mut DbPool<'_>, link_: DbUrl) -> Result<(), Error> { pub async fn validate(pool: &mut DbPool<'_>, link_: DbUrl) -> Result<(), Error> {
let conn = &mut get_conn(pool).await?; let conn = &mut get_conn(pool).await?;
let res = remote_image::table
.find(link_) let exists = select(exists(
.first::<RemoteImage>(conn) remote_image::table.filter(remote_image::link.eq(link_)),
.await ))
.optional()?; .get_result::<bool>(conn)
if res.is_some() { .await?;
if exists {
Ok(()) Ok(())
} else { } else {
Err(NotFound) Err(NotFound)