Browse Source

Fix race condition for isFileInQueue

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
3fe240f6d0

+ 3 - 1
app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt

@@ -86,7 +86,9 @@ class FileDownloadWorker(
         const val EXTRA_ACCOUNT_NAME = "EXTRA_ACCOUNT_NAME"
 
         fun isFileInQueue(user: User, file: OCFile): Boolean {
-            return pendingDownloadFileIds.contains(Pair(user.accountName, file.fileId))
+            synchronized(lock) {
+                return pendingDownloadFileIds.contains(Pair(user.accountName, file.fileId))
+            }
         }
 
         fun cancelCurrentDownload(user: User, file: OCFile) {