[GH-ISSUE #2173] [Bug] The system cannot find the file specified after deleting selected cover image #878

Closed
opened 2026-03-23 20:42:25 +00:00 by mirror · 11 comments
Owner

Originally created by @GouravShDev on GitHub (Apr 3, 2023).
Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/2173

Originally assigned to: @GouravShDev on GitHub.

Bug Description

After deleting the selected image of a document cover will cause the following exception:
(OS Error: The system cannot find the file specified, errno = 2)

How to Reproduce

  • Add a document cover image
  • delete that image through the change cover popup
  • restart the app

Expected Behavior

It should revert back to default no cover image

Operating System

Windows 10

AppFlowy Version(s)

0.1.2

Screenshots

image

image

Additional Context

https://github.com/AppFlowy-IO/AppFlowy/pull/2111#issuecomment-1493578791

Originally created by @GouravShDev on GitHub (Apr 3, 2023). Original GitHub issue: https://github.com/AppFlowy-IO/AppFlowy/issues/2173 Originally assigned to: @GouravShDev on GitHub. ### Bug Description After deleting the selected image of a document cover will cause the following exception: (OS Error: The system cannot find the file specified, errno = 2) ### How to Reproduce - Add a document cover image - delete that image through the change cover popup - restart the app ### Expected Behavior It should revert back to default no cover image ### Operating System Windows 10 ### AppFlowy Version(s) 0.1.2 ### Screenshots ![image](https://user-images.githubusercontent.com/74348508/229584182-e4c21547-47b3-4415-a0c4-1271c80fd78d.png) ![image](https://user-images.githubusercontent.com/74348508/229584135-1820f15b-cb4c-4d61-b61a-8edf3856de71.png) ### Additional Context https://github.com/AppFlowy-IO/AppFlowy/pull/2111#issuecomment-1493578791
mirror 2026-03-23 20:42:25 +00:00
  • closed this issue
  • added the
    editor
    label
Author
Owner

@GouravShDev commented on GitHub (Apr 3, 2023):

I would like to work on this fix. Since, my PR caused it 😅.

<!-- gh-comment-id:1494716468 --> @GouravShDev commented on GitHub (Apr 3, 2023): I would like to work on this fix. Since, my PR caused it 😅.
Author
Owner

@annieappflowy commented on GitHub (Apr 4, 2023):

@GouravShDev , I commented on the previous PR. I think it's better to go back to the default no image cover state after deleting the current cover image.

<!-- gh-comment-id:1495312022 --> @annieappflowy commented on GitHub (Apr 4, 2023): @GouravShDev , I commented on the previous PR. I think it's better to go back to the default no image cover state after deleting the current cover image.
Author
Owner

@GouravShDev commented on GitHub (Apr 5, 2023):

I need suggestion for the possible solution to this issue.
I was thinking to just check for the cover image before creating image widget for that and if it doesn't exists then remove from the database and return empty sizedbox.
But this doesn't update the current document unless app restarts. Should I go with this approach?

I tried to update current document but this cause sudden weird animation in the ui as shown in this video:

https://user-images.githubusercontent.com/74348508/230054301-2a85f68d-a5d5-489f-80c6-00db0a4f719d.mp4

<!-- gh-comment-id:1497716401 --> @GouravShDev commented on GitHub (Apr 5, 2023): I need suggestion for the possible solution to this issue. I was thinking to just check for the cover image before creating image widget for that and if it doesn't exists then remove from the database and return empty sizedbox. But this doesn't update the current document unless app restarts. Should I go with this approach? I tried to update current document but this cause sudden weird animation in the ui as shown in this video: https://user-images.githubusercontent.com/74348508/230054301-2a85f68d-a5d5-489f-80c6-00db0a4f719d.mp4
Author
Owner

@hyj1204 commented on GitHub (Apr 6, 2023):

In my opinion, the ideal solution would be to display a pop-up dialog when a user attempts to delete an image that is currently in use. It can be "This image is currently used in the cover, it will be removed from cover after it is deleted. Do you want to delete it and remove it from the cover? " Yes/No
If the user chooses to proceed, the image should be deleted, and the cover should be updated with a refresh animation(that weird animation could make sense here) to indicate the change. It could be a new feature/improvement to do in a new PR.

For now, it would be best to focus on fixing the error first. I think your first approach is suitable for this situation, and it won't cause any disruptive changes for users when they delete an image that's currently in use.

What do you think? @GouravShDev @annieappflowy

<!-- gh-comment-id:1499323308 --> @hyj1204 commented on GitHub (Apr 6, 2023): In my opinion, the ideal solution would be to display a pop-up dialog when a user attempts to delete an image that is currently in use. It can be "This image is currently used in the cover, it will be removed from cover after it is deleted. Do you want to delete it and remove it from the cover? " Yes/No If the user chooses to proceed, the image should be deleted, and the cover should be updated with a refresh animation(that weird animation could make sense here) to indicate the change. It could be a new feature/improvement to do in a new PR. For now, it would be best to focus on fixing the error first. I think your first approach is suitable for this situation, and it won't cause any disruptive changes for users when they delete an image that's currently in use. What do you think? @GouravShDev @annieappflowy
Author
Owner

@GouravShDev commented on GitHub (Apr 6, 2023):

Definitely agree with you @hyj1204 . I can try adding popup for deleting selected cover image and loading animation but that might take some time. If that first approach is feasible I can create PR for it. And might work on improvement later on.

I found another issue with updating current document cover after deleting selected cover image.

Let's say a image is used as cover for different documents and user deletes that cover image I might be able to update current document but I don't know how can I update all other documents which are using that cover image without app restart.

<!-- gh-comment-id:1499368638 --> @GouravShDev commented on GitHub (Apr 6, 2023): Definitely agree with you @hyj1204 . I can try adding popup for deleting selected cover image and loading animation but that might take some time. If that first approach is feasible I can create PR for it. And might work on improvement later on. I found another issue with updating current document cover after deleting selected cover image. Let's say a image is used as cover for different documents and user deletes that cover image I might be able to update current document but I don't know how can I update all other documents which are using that cover image without app restart.
Author
Owner

@hyj1204 commented on GitHub (Apr 6, 2023):

@GouravShDev
That's a really good point. I agree that it can be difficult to keep track of all the pages linked to an image that is going to be deleted. One solution I could think of it is to separate the cover image used on the page from the cover image used in the gallery. This could be achieved by making a copy of the image each time it is applied and saving it with the page it belongs to. By this way, if the user deletes the image in the gallery, it will not affect anything in the pages until the user chooses to delete it. However, this may cause a lot of cover images to be stored with the pages, I am not sure if it is a good solution to solve this problem at this point.

Another feasible solution I could come up with is to follow the way I suggest before, pop up a dialog, then deleting the cover for current page only, and leave the other pages with deleted cover until user restart the app. After restarting the app, any non-existent cover images will disappear(become Sizedbox).

Let me know what you thought about it.

<!-- gh-comment-id:1499689801 --> @hyj1204 commented on GitHub (Apr 6, 2023): @GouravShDev That's a really good point. I agree that it can be difficult to keep track of all the pages linked to an image that is going to be deleted. One solution I could think of it is to separate the cover image used on the page from the cover image used in the gallery. This could be achieved by making a copy of the image each time it is applied and saving it with the page it belongs to. By this way, if the user deletes the image in the gallery, it will not affect anything in the pages until the user chooses to delete it. However, this may cause a lot of cover images to be stored with the pages, I am not sure if it is a good solution to solve this problem at this point. Another feasible solution I could come up with is to follow the way I suggest before, pop up a dialog, then deleting the cover for current page only, and leave the other pages with deleted cover until user restart the app. After restarting the app, any non-existent cover images will disappear(become Sizedbox). Let me know what you thought about it.
Author
Owner

@GouravShDev commented on GitHub (Apr 8, 2023):

@hyj1204 I am going with the approach of showing popup to user and updating current document . Other documents will update when widget get rebuild. I have created Alert dialog ui for it. I'm working on its functionality rn.
Can you suggest if the UI for the dialog is right?

image

<!-- gh-comment-id:1500913483 --> @GouravShDev commented on GitHub (Apr 8, 2023): @hyj1204 I am going with the approach of showing popup to user and updating current document . Other documents will update when widget get rebuild. I have created Alert dialog ui for it. I'm working on its functionality rn. Can you suggest if the UI for the dialog is right? ![image](https://user-images.githubusercontent.com/74348508/230729311-9d933391-b8f4-465c-a14d-0ba74aeac3cc.png)
Author
Owner

@LucasXu0 commented on GitHub (Apr 10, 2023):

Hey, @GouravShDev. We should add a backup logic for deleting images. If we can't load the image successfully, we have two options: either clear the status of the cover or show the built-in image.

<!-- gh-comment-id:1501285078 --> @LucasXu0 commented on GitHub (Apr 10, 2023): Hey, @GouravShDev. We should add a backup logic for deleting images. If we can't load the image successfully, we have two options: either clear the status of the cover or show the built-in image.
Author
Owner

@GouravShDev commented on GitHub (Apr 10, 2023):

@LucasXu0 I have added backup logic in my PR.
But what about alert dialog for deleting image which is current selected ? Should I keep it or remove it? As it difficult to check if image is used in any document cover.

<!-- gh-comment-id:1501393772 --> @GouravShDev commented on GitHub (Apr 10, 2023): @LucasXu0 I have added backup logic in my PR. But what about alert dialog for deleting image which is current selected ? Should I keep it or remove it? As it difficult to check if image is used in any document cover.
Author
Owner

@LucasXu0 commented on GitHub (Apr 10, 2023):

Should I keep it or remove it? As it difficult to check if image is used in any document cover.

I suggest that we only show the toast if the user deletes the image that's currently being used in the document. @hyj1204 What do you think?

<!-- gh-comment-id:1501453934 --> @LucasXu0 commented on GitHub (Apr 10, 2023): > Should I keep it or remove it? As it difficult to check if image is used in any document cover. I suggest that we only show the toast if the user deletes the image that's currently being used in the document. @hyj1204 What do you think?
Author
Owner

@hyj1204 commented on GitHub (Apr 10, 2023):

@LucasXu0
Yes, I think it is my previous suggestion too. The dialog will pop up only when user intent to delete the cover which is in using in current page. If the image is not used in current page or used in other pages, the dialog won't pop up and the image will be delete immediately.

@GouravShDev
You can use the dialog you already built. I may modify its style later after you code is merged because I gonna refactor all the StyledDialog (maybe with other predefined widgets) later as an independent PR.

<!-- gh-comment-id:1502244558 --> @hyj1204 commented on GitHub (Apr 10, 2023): @LucasXu0 Yes, I think it is my previous suggestion too. The dialog will pop up only when user intent to delete the cover which is in using in current page. If the image is not used in current page or used in other pages, the dialog won't pop up and the image will be delete immediately. @GouravShDev You can use the dialog you already built. I may modify its style later after you code is merged because I gonna refactor all the `StyledDialog` (maybe with other predefined widgets) later as an independent PR.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#878
No description provided.