-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delete previous image on cover change #6368
base: main
Are you sure you want to change the base?
Conversation
Hey @LucasXu0, Is my approach to this issue is correct? |
b795d8a
to
bd9be43
Compare
@LucasXu0 I also noticed that the local image case was not handled in migrateAttributes so I added it. I am working on test cases now. Please let me know if my approach is correct. |
@@ -763,6 +763,7 @@ class DocumentCoverState extends State<DocumentCover> { | |||
} | |||
|
|||
Future<void> onCoverChanged(CoverType type, String? details) async { | |||
await deletePreviousImageIfNecessary(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can perform this after changing the cover. (Since it's an asynchronous operation)
@@ -117,3 +117,7 @@ Future<List<ImageBlockData>> extractAndUploadImages( | |||
|
|||
return images; | |||
} | |||
|
|||
Future<void> deleteImageFromLocalStorage(String localImagePath) async { | |||
await File(localImagePath).delete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we wrap this in try-catch and at least log errors?
Feature Preview
Closes: #5145
I have created two methods for deletePreviousImageFromCloudStorage and deleteFile in DocumentSevce Class
when ever the user changes cover image the this method will check if there the previous image was file, If so then it will delete the previous image.
I have a question ther is a an method DocumentEventDeleteFile which takes DownloadFilePB payload which has two params localFilePath and url, the url can be obtained from coverDetails but localFilepath is not stored any where how do i delete it from the local storage? @Xazin
PR Checklist