Fix cancel notification

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-01-09 11:24:49 +01:00 committed by Alper Öztürk
parent 2754cc6ac6
commit 457f01dfd4

View file

@ -291,6 +291,8 @@ class FileDownloadWorker(
return
}
val fileName = currentDownload?.file?.fileName
setWorkerState(user)
Log_OC.e(TAG, "FilesDownloadWorker downloading: $downloadKey")
@ -317,7 +319,7 @@ class FileDownloadWorker(
Log_OC.e(TAG, "Error downloading", e)
downloadResult = RemoteOperationResult<Any?>(e)
} finally {
cleanupDownloadProcess(downloadResult)
cleanupDownloadProcess(downloadResult, fileName)
}
}
@ -355,9 +357,9 @@ class FileDownloadWorker(
return file
}
private fun cleanupDownloadProcess(result: RemoteOperationResult<*>?) {
private fun cleanupDownloadProcess(result: RemoteOperationResult<*>?, fileName: String?) {
result?.let {
showFailedDownloadNotifications(it)
showFailedDownloadNotifications(it, fileName)
}
val removeResult = pendingDownloads.removePayload(
@ -380,12 +382,11 @@ class FileDownloadWorker(
}
}
private fun showFailedDownloadNotifications(result: RemoteOperationResult<*>) {
private fun showFailedDownloadNotifications(result: RemoteOperationResult<*>, fileName: String?) {
if (result.isSuccess) {
return
}
val fileName = currentDownload?.file?.fileName ?: ""
val failMessage = if (result.isCancelled) {
context.getString(
R.string.downloader_file_download_cancelled,