Skip to content

Improve DocumentsProvider and add tests#6806

Merged
tobiasKaminsky merged 3 commits into
masterfrom
grote/improve-documentsprovider-add-tests
Sep 2, 2020
Merged

Improve DocumentsProvider and add tests#6806
tobiasKaminsky merged 3 commits into
masterfrom
grote/improve-documentsprovider-add-tests

Conversation

@grote

@grote grote commented Aug 25, 2020

Copy link
Copy Markdown
Member

This PR improves the implementation of the DocumentsProvider and adds first instrumentation tests.

Testing

  • Tests written, or not not needed

Closes #6753

@grote
grote force-pushed the grote/improve-documentsprovider-add-tests branch 2 times, most recently from e9a53b7 to 940affd Compare August 26, 2020 15:36
@grote
grote marked this pull request as ready for review August 26, 2020 16:57
grote added 2 commits August 27, 2020 11:18
The initial goal was to make all operations completely synchronous,
so failures can be detected by apps using our DocumentsProvider.

However, `#openDocument()` could not be made fully synchronous,
because we need to wait for the ParcelFileDescriptor we are returning to
close before we can upload a file.
Nextcloud works with locally cached files that only get synchronized to
remote storage.

Things I have tried:

* Use the Handler from the calling I/O Thread:
  not guaranteed to have a prepared Looper,
  so can't always create Handler on that Thread
* Extend ParcelFileDescriptor and override its close() methods:
  For some reason they don't get called when the stream gets closed
* notify the content URI when the upload is complete,
  so callers can wait for the notification:
  works, but is non-standard.
  Other DPs are not doing it,
  so it requires Nextcloud specific code on caller side
  and is still hacky:
  what happens if notification doesn't come? Timeout, but for how long?
* use other ways to get a ParcelFileDescriptor on the file:
  couldn't find anything that would interface with Nextcloud's
  current architecture

Signed-off-by: Torsten Grote <t@grobox.de>
Note there's still some FIXMEs in the tests that hint at bugs discovered
by the tests.

Also this is very incomplete, but a good beginning for further tests.

Signed-off-by: Torsten Grote <t@grobox.de>
@grote
grote force-pushed the grote/improve-documentsprovider-add-tests branch from 940affd to 27f48b3 Compare August 27, 2020 14:46
… [skip ci]

Signed-off-by: nextcloud-android-bot <android@nextcloud.com>
@grote

grote commented Sep 1, 2020

Copy link
Copy Markdown
Member Author

@jmue maybe you also want to have a look!


object DocumentsProviderUtils {

internal fun DocumentFile.getOCFile(storageManager: FileDataStorageManager): OCFile? {

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.

Is there a reason to do this?
Other than that it is now in Kotlin? :)

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/15677.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

Codacy

401

Lint

TypemasterPR
Warnings8181
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings59
Internationalization Warnings9
Multithreaded correctness Warnings9
Performance Warnings73
Security Warnings44
Dodgy code Warnings105
Total326

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings27
Correctness Warnings61
Internationalization Warnings9
Multithreaded correctness Warnings9
Performance Warnings73
Security Warnings44
Dodgy code Warnings106
Total329

@tobiasKaminsky
tobiasKaminsky merged commit f807397 into master Sep 2, 2020
@delete-merged-branch
delete-merged-branch Bot deleted the grote/improve-documentsprovider-add-tests branch September 2, 2020 10:27
@AndyScherzinger AndyScherzinger added this to the Nextcloud App 3.14.0 milestone Sep 2, 2020
@jmue

jmue commented Sep 2, 2020

Copy link
Copy Markdown
Contributor

I tested your changes with the internal android files app using the included archive functionality and some other SAF tools. I encountered no new errors, so I want to give a 👍. Besides that I covered two (previously existing) issues and filled the bug reports here #6883 and here #6884

@grote

grote commented Sep 2, 2020

Copy link
Copy Markdown
Member Author

Thanks @jmue for testing and filing those tickets! The first one I noticed as well, but decided not to tackle it within this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make DocumentsProvider operations synchronous

5 participants