|
@@ -96,7 +96,6 @@ class FileDownloadWorker(
|
|
private val pendingDownloads = IndexedForest<DownloadFileOperation>()
|
|
private val pendingDownloads = IndexedForest<DownloadFileOperation>()
|
|
private var downloadProgressListener = FileDownloadProgressListener()
|
|
private var downloadProgressListener = FileDownloadProgressListener()
|
|
private var currentUser = Optional.empty<User>()
|
|
private var currentUser = Optional.empty<User>()
|
|
- private var startedDownload = false
|
|
|
|
private var storageManager: FileDataStorageManager? = null
|
|
private var storageManager: FileDataStorageManager? = null
|
|
private var downloadClient: OwnCloudClient? = null
|
|
private var downloadClient: OwnCloudClient? = null
|
|
private var user: User? = null
|
|
private var user: User? = null
|
|
@@ -109,7 +108,12 @@ class FileDownloadWorker(
|
|
|
|
|
|
notificationManager.init()
|
|
notificationManager.init()
|
|
addAccountUpdateListener()
|
|
addAccountUpdateListener()
|
|
- startDownloadForEachRequest(requestDownloads)
|
|
|
|
|
|
+
|
|
|
|
+ requestDownloads.forEach {
|
|
|
|
+ downloadFile(it)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setIdleWorkerState()
|
|
|
|
|
|
Log_OC.e(TAG, "FilesDownloadWorker successfully completed")
|
|
Log_OC.e(TAG, "FilesDownloadWorker successfully completed")
|
|
Result.success()
|
|
Result.success()
|
|
@@ -119,11 +123,6 @@ class FileDownloadWorker(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onStopped() {
|
|
|
|
- super.onStopped()
|
|
|
|
- setIdleWorkerState()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private fun getRequestDownloads(): AbstractList<String> {
|
|
private fun getRequestDownloads(): AbstractList<String> {
|
|
conflictUploadId = inputData.keyValueMap[CONFLICT_UPLOAD_ID] as Long?
|
|
conflictUploadId = inputData.keyValueMap[CONFLICT_UPLOAD_ID] as Long?
|
|
val file = gson.fromJson(inputData.keyValueMap[FILE] as String, OCFile::class.java)
|
|
val file = gson.fromJson(inputData.keyValueMap[FILE] as String, OCFile::class.java)
|
|
@@ -190,26 +189,15 @@ class FileDownloadWorker(
|
|
am.addOnAccountsUpdatedListener(this, null, false)
|
|
am.addOnAccountsUpdatedListener(this, null, false)
|
|
}
|
|
}
|
|
|
|
|
|
- private fun startDownloadForEachRequest(requestDownloads: AbstractList<String>) {
|
|
|
|
- val it: Iterator<String> = requestDownloads.iterator()
|
|
|
|
-
|
|
|
|
- while (it.hasNext()) {
|
|
|
|
- val next = it.next()
|
|
|
|
- Log_OC.e(TAG, "Download Key: $next")
|
|
|
|
- downloadFile(next)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- startedDownload = false
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Suppress("TooGenericExceptionCaught")
|
|
@Suppress("TooGenericExceptionCaught")
|
|
private fun downloadFile(downloadKey: String) {
|
|
private fun downloadFile(downloadKey: String) {
|
|
- startedDownload = true
|
|
|
|
currentDownload = pendingDownloads.get(downloadKey)
|
|
currentDownload = pendingDownloads.get(downloadKey)
|
|
|
|
|
|
if (currentDownload == null) {
|
|
if (currentDownload == null) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ Log_OC.e(TAG, "FilesDownloadWorker downloading: $downloadKey")
|
|
setWorkerState(user, currentDownload)
|
|
setWorkerState(user, currentDownload)
|
|
|
|
|
|
val isAccountExist = accountManager.exists(currentDownload?.user?.toPlatformAccount())
|
|
val isAccountExist = accountManager.exists(currentDownload?.user?.toPlatformAccount())
|