amake / orgro

An Org Mode app for iOS and Android
https://orgro.org
GNU General Public License v3.0
503 stars 23 forks source link

Unable to grant permission to view relative links #68

Closed r4dian closed 2 years ago

r4dian commented 2 years ago

Expected result : Now the file is visible in the Orgo app

Actual result : The file doesn't load, the user is shown the same prompt

Thing Version
OS Android
Android 12
Orgo latest off f-Droid, about screen just says "dev"

Screenshot_20221011-142628 Screenshot_20221011-142619

amake commented 2 years ago

Thanks for the report. It sounds like you're doing everything right; the thing that jumps out to me is that the files are stored in Nextcloud. I signed up for and downloaded Nextcloud, and was able to reproduce the issue.

I don't know yet if they're doing something wrong, or if I am.

amake commented 2 years ago

With a debug build I see the problem:

D/FilePickerWritable(16582): Got method call: getDirectory
W/DocumentsContract(16582): Failed to find path
W/DocumentsContract(16582): java.lang.UnsupportedOperationException: findDocumentPath not supported.
W/DocumentsContract(16582):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:174)
W/DocumentsContract(16582):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
W/DocumentsContract(16582):     at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
W/DocumentsContract(16582):     at android.content.ContentResolver.call(ContentResolver.java:2405)
W/DocumentsContract(16582):     at android.provider.DocumentsContract.findDocumentPath(DocumentsContract.java:1634)
W/DocumentsContract(16582):     at codeux.design.filepicker.file_picker_writable.QueryKt$getParent$2.invokeSuspend(Query.kt:92)
W/DocumentsContract(16582):     at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
W/DocumentsContract(16582):     at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
W/DocumentsContract(16582):     at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
W/DocumentsContract(16582):     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
W/DocumentsContract(16582):     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
W/DocumentsContract(16582):     at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
D/FilePickerWritable(16582): Error while handling method call io.flutter.plugin.common.MethodCall@c30eb46
D/FilePickerWritable(16582): java.lang.UnsupportedOperationException: findDocumentPath not supported.
D/FilePickerWritable(16582):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:174)
D/FilePickerWritable(16582):    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
D/FilePickerWritable(16582):    at android.content.ContentProviderProxy.call(ContentProviderNative.java:732)
D/FilePickerWritable(16582):    at android.content.ContentResolver.call(ContentResolver.java:2405)
D/FilePickerWritable(16582):    at android.provider.DocumentsContract.findDocumentPath(DocumentsContract.java:1634)
D/FilePickerWritable(16582):    at codeux.design.filepicker.file_picker_writable.QueryKt$getParent$2.invokeSuspend(Query.kt:92)
D/FilePickerWritable(16582):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
D/FilePickerWritable(16582):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
D/FilePickerWritable(16582):    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
D/FilePickerWritable(16582):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
D/FilePickerWritable(16582):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
D/FilePickerWritable(16582):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

It appears that Nextcloud doesn't support DocumentsContract.findDocumentPath. This method is needed in order to resolve relative paths.

So while you can successfully grant access to a Nextcloud directory, that access doesn't allow resolving relative paths, which is why Orgro still prompts you to grant permission.

I don't think there's anything I can do about this, unless I have overlooked something in my implementation of path resolving that would allow me to eliminate calls to findDocumentPath (and any other methods not supported by Nextcloud).

amake commented 2 years ago

Actually I did have an alternate method of path resolving meant for older OSs. It's slow and it doesn't allow referencing parent directories (..) but it will allow siblings and lower. I will put out a fix soon.

amake commented 2 years ago

This will be addressed in v1.26.0, which should hit the beta test channels soon:

However even with that solved, I see that Nextcloud seems to have some issues with persistent access to files: trying to visit a previously opened file from the Orgro top screen will fail after a while.

r4dian commented 2 years ago

Little extra info, although it seems you've figured it out :

If I go in nextcloud app and select the org file - > open with... - > Orgo then it doesn't ask for permissions in Orgo but where the image would be is a message "can't resolve path relative to document"

amake commented 2 years ago

If I go in nextcloud app and select the org file - > open with... - > Orgo

On Android this results in an extremely limited form of access that doesn't allow resolving against directory permissions.

amake commented 2 years ago

v1.26.1 is now available through all channels.

Please reopen if the issue persists.