nextcloud / nextcloud/android

Optimization step 2 - when doubleCheck is removed

Open
#5,208 0 comments 0 reactions 1 assignee Claimed by @JorisBodin View on GitHub
enhancement performance 🚀
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

![image](https://user-images.githubusercontent.com/2796439/72160596-dba44480-33be-11ea-802a-2ad32578a4a8.png)

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.