use IO thread

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-02 10:14:06 +01:00 committed by Alper Öztürk
parent a8bff664bb
commit 2b576a052b

View file

@ -15,6 +15,8 @@ import com.owncloud.android.datamodel.FileDataStorageManager
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.operations.DownloadFileOperation
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
class SyncWorker(
private val user: User,
@ -29,12 +31,13 @@ class SyncWorker(
@Suppress("DEPRECATION")
override suspend fun doWork(): Result {
return withContext(Dispatchers.IO) {
// TODO add notifications
Log_OC.d(TAG, "SyncWorker started")
val filePaths = inputData.getStringArray(FILE_PATHS)
if (filePaths.isNullOrEmpty()) {
return Result.failure()
return@withContext Result.failure()
}
val fileDataStorageManager = FileDataStorageManager(user, context.contentResolver)
@ -57,7 +60,7 @@ class SyncWorker(
// TODO add isDownloading
// TODO add cancel only one file download
return if (result) {
if (result) {
Log_OC.d(TAG, "SyncWorker completed")
Result.success()
} else {
@ -66,3 +69,4 @@ class SyncWorker(
}
}
}
}