@@ -13,6 +13,7 @@ import androidx.work.WorkerParameters
13
13
import com.nextcloud.client.account.UserAccountManager
14
14
import com.nextcloud.client.device.PowerManagementService
15
15
import com.nextcloud.client.network.ConnectivityService
16
+ import com.nextcloud.client.preferences.AppPreferences
16
17
import com.owncloud.android.MainApp
17
18
import com.owncloud.android.datamodel.FileDataStorageManager
18
19
import com.owncloud.android.datamodel.OCFile
@@ -21,13 +22,14 @@ import com.owncloud.android.operations.SynchronizeFolderOperation
21
22
import com.owncloud.android.utils.FileStorageUtils
22
23
import java.io.File
23
24
24
- @Suppress(" Detekt.NestedBlockDepth" , " ReturnCount" )
25
+ @Suppress(" Detekt.NestedBlockDepth" , " ReturnCount" , " LongParameterList " )
25
26
class InternalTwoWaySyncWork (
26
27
private val context : Context ,
27
28
params : WorkerParameters ,
28
29
private val userAccountManager : UserAccountManager ,
29
30
private val powerManagementService : PowerManagementService ,
30
- private val connectivityService : ConnectivityService
31
+ private val connectivityService : ConnectivityService ,
32
+ private val appPreferences : AppPreferences
31
33
) : Worker(context, params) {
32
34
private var shouldRun = true
33
35
@@ -36,7 +38,9 @@ class InternalTwoWaySyncWork(
36
38
37
39
var result = true
38
40
39
- if (powerManagementService.isPowerSavingEnabled ||
41
+ @Suppress(" ComplexCondition" )
42
+ if (! appPreferences.isTwoWaySyncEnabled ||
43
+ powerManagementService.isPowerSavingEnabled ||
40
44
! connectivityService.isConnected ||
41
45
connectivityService.isInternetWalled ||
42
46
! connectivityService.connectivity.isWifi
@@ -61,13 +65,6 @@ class InternalTwoWaySyncWork(
61
65
return checkFreeSpaceResult
62
66
}
63
67
64
- // do not attempt to sync root folder
65
- if (folder.remotePath == OCFile .ROOT_PATH ) {
66
- folder.internalFolderSyncTimestamp = - 1L
67
- fileDataStorageManager.saveFile(folder)
68
- continue
69
- }
70
-
71
68
Log_OC .d(TAG , " Folder ${folder.remotePath} : started!" )
72
69
val operation = SynchronizeFolderOperation (context, folder.remotePath, user, fileDataStorageManager)
73
70
.execute(context)
0 commit comments