add Constraints

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-12-19 10:25:53 +01:00
parent 4f7dde0b17
commit b2b87a831e
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

View file

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