mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-25 04:11:31 +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> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
let res = remote_image::table
|
||||
.find(link_)
|
||||
.first::<RemoteImage>(conn)
|
||||
.await
|
||||
.optional()?;
|
||||
if res.is_some() {
|
||||
|
||||
let exists = select(exists(
|
||||
remote_image::table.filter(remote_image::link.eq(link_)),
|
||||
))
|
||||
.get_result::<bool>(conn)
|
||||
.await?;
|
||||
if exists {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(NotFound)
|
||||
|
|
Loading…
Reference in a new issue