Update crates/api_common/src/request.rs

Co-authored-by: dullbananas <dull.bananas0@gmail.com>
This commit is contained in:
Dessalines 2024-06-03 17:48:15 -04:00 committed by GitHub
parent 5f340d979d
commit cb9a3aa7b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -345,8 +345,9 @@ pub async fn replace_image(
context: &Data<LemmyContext>,
) -> LemmyResult<()> {
if let (Some(new_image), Some(old_image)) = (new_image, old_image) {
// Note: Oftentimes front ends will include the current image in the form,
// so only delete if the urls are different.
// Note: Oftentimes front ends will include the current image in the form.
// In this case, deleting `old_image` would also be deletion of `new_image`,
// so the deletion must be skipped for the image to be kept.
if new_image != old_image.as_str() {
// Ignore errors because image may be stored externally.
let image = LocalImage::delete_by_url(&mut context.pool(), old_image)