orgro icon indicating copy to clipboard operation
orgro copied to clipboard

Unable to grant permission to view relative links

Open r4dian opened this issue 3 years ago • 6 comments

  • Open a file with a relative link in, in this case its :file:./python-matplot-fig.png
  • Choose the option grant access
  • Navigate to the folder that contains the file in question (or any folder above it in the tree)
  • Use "use this folder" button
  • Click "allow"

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

r4dian avatar Oct 11 '22 13:10 r4dian

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 avatar Oct 11 '22 14:10 amake

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 avatar Oct 11 '22 23:10 amake

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 avatar Oct 12 '22 05:10 amake

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.

amake avatar Oct 12 '22 06:10 amake

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"

r4dian avatar Oct 14 '22 14:10 r4dian

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 avatar Oct 14 '22 14:10 amake

v1.26.1 is now available through all channels.

Please reopen if the issue persists.

amake avatar Nov 07 '22 14:11 amake