Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Ahad-patel
Copy link
Contributor

@Ahad-patel Ahad-patel commented Sep 20, 2024

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

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

@CLAassistant
Copy link

CLAassistant commented Sep 20, 2024

CLA assistant check
All committers have signed the CLA.

@Ahad-patel Ahad-patel changed the title delete previous image on cover change #5145 delete previous image on cover change Sep 20, 2024
@Ahad-patel Ahad-patel marked this pull request as draft September 20, 2024 16:04
@Ahad-patel
Copy link
Contributor Author

Hey @LucasXu0, Is my approach to this issue is correct?

@Ahad-patel Ahad-patel marked this pull request as ready for review October 21, 2024 16:42
@Ahad-patel
Copy link
Contributor Author

@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();
Copy link
Collaborator

@Xazin Xazin Oct 21, 2024

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();
Copy link
Collaborator

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?

@Xazin Xazin requested a review from LucasXu0 October 21, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Delete Unnecessary images from the "Image" folder.
3 participants