mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-01 16:51:21 +00:00
Update crates/api_common/src/request.rs
Co-authored-by: dullbananas <dull.bananas0@gmail.com>
This commit is contained in:
parent
5f340d979d
commit
cb9a3aa7b9
1 changed files with 3 additions and 2 deletions
|
@ -345,8 +345,9 @@ pub async fn replace_image(
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
) -> LemmyResult<()> {
|
) -> LemmyResult<()> {
|
||||||
if let (Some(new_image), Some(old_image)) = (new_image, old_image) {
|
if let (Some(new_image), Some(old_image)) = (new_image, old_image) {
|
||||||
// Note: Oftentimes front ends will include the current image in the form,
|
// Note: Oftentimes front ends will include the current image in the form.
|
||||||
// so only delete if the urls are different.
|
// 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() {
|
if new_image != old_image.as_str() {
|
||||||
// Ignore errors because image may be stored externally.
|
// Ignore errors because image may be stored externally.
|
||||||
let image = LocalImage::delete_by_url(&mut context.pool(), old_image)
|
let image = LocalImage::delete_by_url(&mut context.pool(), old_image)
|
||||||
|
|
Loading…
Reference in a new issue