mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-27 06:41:18 +00:00
Use select exists again.
This commit is contained in:
parent
8a0b7c05d3
commit
f7592fdf34
1 changed files with 7 additions and 6 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue