Remove network constrait for periodically offline operation

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-08-15 10:36:18 +02:00
parent 27897950fe
commit c8a6d819d3
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
2 changed files with 9 additions and 6 deletions

View file

@ -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()

View file

@ -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 -> {