@@ -19,6 +19,7 @@ import com.nextcloud.client.database.entity.toOCUpload
1919import com.nextcloud.client.database.entity.toUploadEntity
2020import com.nextcloud.client.device.PowerManagementService
2121import com.nextcloud.client.jobs.upload.FileUploadEventBroadcaster
22+ import com.nextcloud.client.jobs.upload.FileUploadHelper
2223import com.nextcloud.client.jobs.upload.FileUploadWorker
2324import com.nextcloud.client.jobs.utils.UploadErrorNotificationManager
2425import com.nextcloud.client.network.ConnectivityService
@@ -38,8 +39,10 @@ import com.owncloud.android.lib.common.OwnCloudAccount
3839import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
3940import com.owncloud.android.lib.common.operations.RemoteOperationResult
4041import com.owncloud.android.lib.common.utils.Log_OC
42+ import com.owncloud.android.lib.resources.status.OCCapability
4143import com.owncloud.android.operations.UploadFileOperation
4244import com.owncloud.android.ui.activity.SettingsActivity
45+ import com.owncloud.android.utils.theme.CapabilityUtils
4346import com.owncloud.android.utils.theme.ViewThemeUtils
4447import kotlinx.coroutines.Dispatchers
4548import kotlinx.coroutines.ensureActive
@@ -73,6 +76,7 @@ class AutoUploadWorker(
7376 private val fileUploadEventBroadcaster = FileUploadEventBroadcaster (localBroadcastManager)
7477 private lateinit var syncedFolder: SyncedFolder
7578 private val notificationManager = AutoUploadNotificationManager (context, viewThemeUtils, NOTIFICATION_ID )
79+ private val fileUploadHelper = FileUploadHelper .instance()
7680
7781 @Suppress(" ReturnCount" )
7882 override suspend fun doWork (): Result {
@@ -243,6 +247,7 @@ class AutoUploadWorker(
243247 val ocAccount = OwnCloudAccount (user.toPlatformAccount(), context)
244248 val client = OwnCloudClientManagerFactory .getDefaultSingleton()
245249 .getClientFor(ocAccount, context)
250+ val capability = CapabilityUtils .getCapability(user, context)
246251
247252 updateNotification()
248253
@@ -265,7 +270,7 @@ class AutoUploadWorker(
265270 val remotePath = syncFolderHelper.getAutoUploadRemotePath(syncedFolder, file)
266271
267272 try {
268- val entityResult = getEntityResult(user, localPath, remotePath)
273+ val entityResult = getEntityResult(user, localPath, remotePath, capability )
269274 if (entityResult !is AutoUploadEntityResult .Success ) {
270275 repository.markFileAsHandled(localPath, syncedFolder)
271276 Log_OC .d(TAG , " marked file as handled: $localPath " )
@@ -358,12 +363,17 @@ class AutoUploadWorker(
358363 }
359364
360365 @Suppress(" ReturnCount" )
361- private fun getEntityResult (user : User , localPath : String , remotePath : String ): AutoUploadEntityResult {
366+ private fun getEntityResult (
367+ user : User ,
368+ localPath : String ,
369+ remotePath : String ,
370+ capability : OCCapability
371+ ): AutoUploadEntityResult {
362372 val (needsCharging, needsWifi, uploadAction) = getUploadSettings(syncedFolder)
363373 Log_OC .d(TAG , " creating oc upload for ${user.accountName} " )
364374
365375 // Get existing upload or create new one
366- val uploadEntity = uploadsStorageManager.uploadDao.getUploadByAccountAndPaths (
376+ val uploadEntity = fileUploadHelper.getUploadByPaths (
367377 localPath = localPath,
368378 remotePath = remotePath,
369379 accountName = user.accountName
@@ -379,7 +389,7 @@ class AutoUploadWorker(
379389 }
380390
381391 val upload = try {
382- uploadEntity?.toOCUpload(null ) ? : OCUpload (localPath, remotePath, user.accountName)
392+ uploadEntity?.toOCUpload(capability ) ? : OCUpload (localPath, remotePath, user.accountName)
383393 } catch (_: IllegalArgumentException ) {
384394 Log_OC .e(TAG , " cannot construct oc upload" )
385395 return AutoUploadEntityResult .CreationError
0 commit comments