Fix FileDownloaderBinder cancelAllDownloadsForAccount

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-12-28 09:54:03 +01:00 committed by Alper Öztürk
parent efe6649b69
commit e3d8e85337
2 changed files with 7 additions and 6 deletions

View file

@ -155,8 +155,8 @@ class FileDownloadWorker(
downloadType
)
operation.addDatatransferProgressListener(this)
operation.addDatatransferProgressListener(downloadBinder as FileDownloaderBinder)
operation.addDownloadDataTransferProgressListener(this)
operation.addDownloadDataTransferProgressListener(downloadBinder as FileDownloaderBinder)
val putResult = pendingDownloads.putIfAbsent(
user?.accountName,
file.remotePath,
@ -203,7 +203,7 @@ class FileDownloadWorker(
val isAccountExist = accountManager.exists(currentDownload?.user?.toPlatformAccount())
if (!isAccountExist) {
cancelPendingDownloads(currentDownload?.user?.accountName)
removePendingDownload(currentDownload?.user?.accountName)
return
}
@ -228,7 +228,7 @@ class FileDownloadWorker(
}
}
private fun cancelPendingDownloads(accountName: String?) {
private fun removePendingDownload(accountName: String?) {
pendingDownloads.remove(accountName)
}
@ -358,10 +358,11 @@ class FileDownloadWorker(
fun cancelAllDownloadsForAccount(accountName: String?) {
if (currentDownload?.user?.nameEquals(accountName) == true) {
context.cancelWork(JOB_FILES_DOWNLOAD)
currentDownload?.cancel()
}
cancelPendingDownloads(accountName)
removePendingDownload(accountName)
}
fun isDownloading(): Boolean {

View file

@ -260,7 +260,7 @@ public class DownloadFileOperation extends RemoteOperation {
}
public void addDatatransferProgressListener (OnDatatransferProgressListener listener) {
public void addDownloadDataTransferProgressListener(OnDatatransferProgressListener listener) {
synchronized (dataTransferListeners) {
dataTransferListeners.add(listener);
}