Skip to content

Commit

Permalink
Add user check for isFileInQueue
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Jan 8, 2024
1 parent a17933f commit 31654db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FileDownloadHelper {
return false
}

return FileDownloadWorker.isFileInQueue(file) ||
return FileDownloadWorker.isFileInQueue(user, file) ||
(file.isFolder && backgroundJobManager.isStartFileDownloadJobScheduled(user, file))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class FileDownloadWorker(
private val TAG = FileDownloadWorker::class.java.simpleName

private var currentDownload: DownloadFileOperation? = null
private var pendingDownloadFileIds: ArrayList<Long> = arrayListOf()
private var pendingDownloadFileIds: ArrayList<Pair<String?, Long>> = arrayListOf()
private val lock = Any()

const val FILES_SEPARATOR = ","
Expand All @@ -85,8 +85,8 @@ class FileDownloadWorker(
const val EXTRA_LINKED_TO_PATH = "EXTRA_LINKED_TO_PATH"
const val EXTRA_ACCOUNT_NAME = "EXTRA_ACCOUNT_NAME"

fun isFileInQueue(file: OCFile): Boolean {
return pendingDownloadFileIds.contains(file.fileId)
fun isFileInQueue(user: User, file: OCFile): Boolean {
return pendingDownloadFileIds.contains(Pair(user.accountName, file.fileId))
}

fun cancelCurrentDownload(user: User, file: OCFile) {
Expand Down Expand Up @@ -228,7 +228,7 @@ class FileDownloadWorker(
file.remotePath,
operation
)
pendingDownloadFileIds.add(file.fileId)
pendingDownloadFileIds.add(Pair(user?.accountName, file.fileId))

if (downloadKey != null) {
requestedDownloads.add(downloadKey)
Expand Down Expand Up @@ -377,7 +377,7 @@ class FileDownloadWorker(
currentDownload?.user?.accountName,
currentDownload?.remotePath
)
pendingDownloadFileIds.remove(currentDownload?.file?.fileId)
pendingDownloadFileIds.remove(Pair(currentDownload?.user?.accountName, currentDownload?.file?.fileId))

val downloadResult = result ?: RemoteOperationResult<Any?>(RuntimeException("Error downloading…"))

Expand Down

0 comments on commit 31654db

Please sign in to comment.