diff --git a/api_tests/src/image.spec.ts b/api_tests/src/image.spec.ts index a335b9cad7..961eed50cb 100644 --- a/api_tests/src/image.spec.ts +++ b/api_tests/src/image.spec.ts @@ -128,6 +128,7 @@ test.only("Purge user, uploaded image removed", async () => { }; const delete_ = await alphaImage.purgePerson(purgeForm); expect(delete_.success).toBe(true); + console.log(upload.image_url + " should be purged"); // ensure that image is deleted const response2 = await fetch(upload.image_url ?? ""); diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index 5428c4c4b4..9d49651427 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -327,6 +327,9 @@ pub async fn purge_image_from_pictrs(image_url: &Url, context: &LemmyContext) -> .next_back() .ok_or(LemmyErrorType::ImageUrlMissingLastPathSegment)?; + // Delete db row if any (old Lemmy versions didnt generate this). + LocalImage::delete_by_alias(&mut context.pool(), &alias).await.ok(); + let pictrs_config = context.settings().pictrs()?; let purge_url = format!("{}internal/purge?alias={}", pictrs_config.url, alias); @@ -355,6 +358,9 @@ pub async fn delete_image_from_pictrs( delete_token: &str, context: &LemmyContext, ) -> LemmyResult<()> { + // Delete db row if any (old Lemmy versions didnt generate this). + LocalImage::delete_by_alias(&mut context.pool(), &alias).await.ok(); + let pictrs_config = context.settings().pictrs()?; let url = format!( "{}image/delete/{}/{}",