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

Fix crash in share Media, fix failed download media #1213

Merged
merged 2 commits into from
Sep 4, 2023

Conversation

MV-GH
Copy link
Collaborator

@MV-GH MV-GH commented Sep 3, 2023

Learned quite a bit from this. The original share/download since the introduction of the caching check was only really working in some instances due to some quirks.

mistakes:

  • scope.launch won't rethrow unhandled exceptions but will cancel its parents thus bypassing the try catch I had
  • shareMedia used scope.launch for the IO part but it did not actually wait for this complete, thus it was sharing empty files at best crash at worst due to two sources reading/write to a cache file (only really worked in the rare instance its called from imageviewer where the image is loaded in cache and it wins the race condition on reading the file into the cached file)
  • Context.getInputStream shared a closed inputStream, the implementation for snapshot doesn't actually check if it is closed thus that worked. But the byteStream implementation did. Thus the cause of the IOException: Closed exception

Fixes #1204

Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dessalines dessalines merged commit 6a08901 into LemmyNet:main Sep 4, 2023
@MV-GH MV-GH deleted the fix/1204 branch September 20, 2023 16:05
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.

Sometimes crash when sharing images
2 participants