mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
Remove network constrait for periodically offline operation
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
27897950fe
commit
c8a6d819d3
2 changed files with 9 additions and 6 deletions
|
@ -423,15 +423,10 @@ internal class BackgroundJobManagerImpl(
|
|||
.putString(OfflineOperationsWorker.JOB_NAME, JOB_PERIODIC_OFFLINE_OPERATIONS)
|
||||
.build()
|
||||
|
||||
val constraints = Constraints.Builder()
|
||||
.setRequiredNetworkType(NetworkType.CONNECTED)
|
||||
.build()
|
||||
|
||||
val request = periodicRequestBuilder(
|
||||
jobClass = OfflineOperationsWorker::class,
|
||||
jobName = JOB_PERIODIC_OFFLINE_OPERATIONS,
|
||||
intervalMins = OFFLINE_OPERATIONS_PERIODIC_JOB_INTERVAL_MINUTES,
|
||||
constraints = constraints
|
||||
)
|
||||
.setInputData(inputData)
|
||||
.build()
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.nextcloud.client.account.User
|
|||
import com.nextcloud.client.database.entity.OfflineOperationEntity
|
||||
import com.nextcloud.client.network.ClientFactoryImpl
|
||||
import com.nextcloud.model.OfflineOperationType
|
||||
import com.nextcloud.receiver.NetworkChangeReceiver
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
|
@ -40,9 +41,14 @@ class OfflineOperationsWorker(
|
|||
"$jobName -----------------------------------\nOfflineOperationsWorker started\n-----------------------------------"
|
||||
)
|
||||
|
||||
if (NetworkChangeReceiver.isNetworkAvailable(context)) {
|
||||
Log_OC.d(TAG, "OfflineOperationsWorker cancelled, no internet connection.")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
val offlineOperations = fileDataStorageManager.offlineOperationDao.getAll()
|
||||
if (offlineOperations.isEmpty()) {
|
||||
Log_OC.d(TAG, "OfflineOperationsWorker completed successfully, no offline operations were found.")
|
||||
Log_OC.d(TAG, "OfflineOperationsWorker cancelled, no offline operations were found.")
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
|
@ -53,6 +59,8 @@ class OfflineOperationsWorker(
|
|||
createFolder(operation, client, onCompleted = {
|
||||
fileDataStorageManager.offlineOperationDao.delete(operation)
|
||||
})
|
||||
|
||||
// TODO update UI after operation completions
|
||||
}
|
||||
|
||||
null -> {
|
||||
|
|
Loading…
Reference in a new issue