Android: Fix sharing items from Joplin#4718
Merged
laurent22 merged 10 commits intolaurent22:devfrom Apr 7, 2021
Merged
Conversation
…pps. Instead store it in the caches dir and clear it on Joplin startup
Contributor
Author
This has been fixed in the latest version, I've updated the PR |
laurent22
reviewed
Mar 26, 2021
Owner
|
Thanks for the update @roman-r-m! |
|
@laurent22 - it is quite critical to have sharing functionality, especially while on travel... When to expect to have it rolled out to production? Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is prompted by this bug report on the forum: https://discourse.joplinapp.org/t/android-lost-access-to-resources/15716/4
The issue here is a combination of 2 older bugs I've fixed before: #4557 & #4373 and a quirk in how Joplin handles deletion.
Because of one of the above bugs, a resource ended up stored in Joplin with an empty title.
When the user shared the resource, Joplin tried to copy the resource to give it the original name (taken from the title), but since the title was empty the copy failed.
joplin/packages/app-mobile/components/NoteBodyViewer/hooks/useOnResourceLongPress.ts
Lines 27 to 32 in ccbc329
For some reason RN copy implementation deletes the target in case of an error:
joplin/packages/app-mobile/utils/fs-driver-rn.ts
Lines 141 to 149 in 42c80e6
In this case the target was the resource dir and this is how the user lost all his resources.
Changes in this PR:
untitledShare.Openreturns before the user has confirmed sharing, so Joplin deletes the file, and when the user finally confirms, the file is already gone. To fix this I've removed deletion. However according to Android docs the cache is not cleaned automatically so I've added a cleanup step on the app startup.react-native-sharehas a bug (which I've introduced there myself), until it's fixed (in Android: fix sharing a single file react-native-share/react-native-share#984) I downgraded the version With it sharing works even though there's an exception in Android logWhile there is no such bug on iOS, as far as I know, these changes use only the API available on both platforms, so I believe it should be compatible with iOS.