From 65dc40f73e164f030769667b4868d8e9a28528cb Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Sat, 30 May 2026 10:58:04 +0800 Subject: [PATCH] skip per-file database lookup on first folder sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When syncing a folder with many files for the first time, each remote file triggered a ContentProvider getFileByPath() query. For a directory with 1000+ files, this meant 1000+ individual database lookups — all of which returned null because the files did not exist locally yet. Skip the per-file fallback when localFilesMap is empty, since no local state exists to merge. Signed-off-by: berlin2123 <68841407+berlin2123@users.noreply.github.com> --- .../owncloud/android/operations/RefreshFolderOperation.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java b/app/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java index 9dbfddc41289..e9581f64a0b8 100644 --- a/app/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java @@ -569,6 +569,8 @@ private void synchronizeData(List folderAndFiles) { OCFile updatedFile; RemoteFile remote; + final boolean skipGetFileByPath = localFilesMap.isEmpty(); + for (int i = 1; i < folderAndFiles.size(); i++) { /// new OCFile instance with the data from the server remote = (RemoteFile) folderAndFiles.get(i); @@ -582,7 +584,7 @@ private void synchronizeData(List folderAndFiles) { localFile = localFilesMap.remove(remoteFile.getRemotePath()); // TODO better implementation is needed - if (localFile == null) { + if (localFile == null && !skipGetFileByPath) { localFile = fileDataStorageManager.getFileByPath(updatedFile.getRemotePath()); }