Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
dessalines merged 2 commits into
LemmyNet:mainfrom
MV-GH:fix/1204
Sep 4, 2023
Merged

Fix crash in share Media, fix failed download media#1213
dessalines merged 2 commits into
LemmyNet:mainfrom
MV-GH:fix/1204

Conversation

@MV-GH

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

Copy link
Copy Markdown
Collaborator

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

@dessalines dessalines left a comment

Copy link
Copy Markdown
Member

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