From b2b87a831e83432f51337b4a7ac4212e5534f242 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Thu, 19 Dec 2024 10:25:53 +0100 Subject: [PATCH] add Constraints Signed-off-by: alperozturk --- .../com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt index 21473ae9d9..bd503302a8 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/BackgroundJobManagerImpl.kt @@ -720,6 +720,11 @@ internal class BackgroundJobManagerImpl( val tag = getSyncFolderTag(folderId) val filePaths = files.map { it.decryptedRemotePath } + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED) + .setRequiresStorageNotLow(true) + .build() + val data = Data.Builder() .putStringArray(SyncWorker.FILE_PATHS, filePaths.toTypedArray()) .build() @@ -727,6 +732,7 @@ internal class BackgroundJobManagerImpl( val request = oneTimeRequestBuilder(SyncWorker::class, JOB_SYNC_FOLDER) .addTag(tag) .setInputData(data) + .setConstraints(constraints) .build() workManager.enqueueUniqueWork(JOB_SYNC_FOLDER, ExistingWorkPolicy.REPLACE, request)