Optimization step 2 - when doubleCheck is removed
- Dominant language
- Kotlin
- Stars
- 5.6k
- Forks
- 2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 92
Description
See this issues https://github.com/nextcloud/android/pull/5150 when doubleCheck is removed in FileContentProfider

This check is here because _saveFolder_ (in _FileDataStorageManager_) is sometimes called twice for an insert.
I've found two cases where that happens, one of which is simple to fix.
The first time the application is started, the _WRITE_EXTERNAL_STORAGE_ permission is requested. When the user accepts, _syncAndUpdateFolder_ is called in _onResume_ and in _onRequestPermissionsResult_.
Delete _syncAndUpdateFolder_ in _onRequestPermissionsResult_ is solution.
Also the first time the application is started, if refreshing the folder, _syncAndUpdateFolder_ is called twice
The solution would be to block the simultaneous call of _saveFolder_.
Benchmark
**If doubleCheck is removed:**
Insert (first download):
**13** seconds.
Update (refresh):
**6** seconds
First I will correct this by removing the double call of syncAndUpdateFolder. The branch is called optimization-step2
And I'm gonna look for other parts of the app where there could be that problem. And I'll see if I can synchronize the saveFolder calls.
Contributor guide
Assessment
This issue has not been assessed yet.