mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
fix spotless
Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
parent
46eaf83a5a
commit
8bb1eaaf2e
5 changed files with 23 additions and 12 deletions
|
@ -128,7 +128,7 @@ interface BackgroundJobManager {
|
|||
fun startImmediateFilesSyncJob(
|
||||
syncedFolderID: Long,
|
||||
overridePowerSaving: Boolean = false,
|
||||
changedFiles: Array<String> = arrayOf<String>(),
|
||||
changedFiles: Array<String> = arrayOf<String>()
|
||||
)
|
||||
|
||||
fun scheduleOfflineSync()
|
||||
|
|
|
@ -405,8 +405,8 @@ internal class BackgroundJobManagerImpl(
|
|||
}
|
||||
|
||||
override fun bothFilesSyncJobsRunning(syncedFolderID: Long): Boolean {
|
||||
return workManager.isWorkRunning(JOB_PERIODIC_FILES_SYNC+"_"+syncedFolderID) &&
|
||||
workManager.isWorkRunning(JOB_IMMEDIATE_FILES_SYNC+"_"+syncedFolderID)
|
||||
return workManager.isWorkRunning(JOB_PERIODIC_FILES_SYNC + "_" + syncedFolderID) &&
|
||||
workManager.isWorkRunning(JOB_IMMEDIATE_FILES_SYNC + "_" + syncedFolderID)
|
||||
}
|
||||
|
||||
override fun schedulePeriodicFilesSyncJob(
|
||||
|
@ -429,7 +429,7 @@ internal class BackgroundJobManagerImpl(
|
|||
override fun startImmediateFilesSyncJob(
|
||||
syncedFolderID: Long,
|
||||
overridePowerSaving: Boolean,
|
||||
changedFiles: Array<String>,
|
||||
changedFiles: Array<String>
|
||||
) {
|
||||
val arguments = Data.Builder()
|
||||
.putBoolean(FilesSyncWork.OVERRIDE_POWER_SAVING, overridePowerSaving)
|
||||
|
|
|
@ -54,7 +54,12 @@ class ContentObserverWork(
|
|||
for (uri in params.triggeredContentUris) {
|
||||
changedFiles.add(uri.toString())
|
||||
}
|
||||
FilesSyncHelper.startFilesSyncForAllFolders(syncedFolderProvider, backgroundJobManager, false, changedFiles.toTypedArray())
|
||||
FilesSyncHelper.startFilesSyncForAllFolders(
|
||||
syncedFolderProvider,
|
||||
backgroundJobManager,
|
||||
false,
|
||||
changedFiles.toTypedArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ class FilesSyncWork(
|
|||
|
||||
private lateinit var syncedFolder: SyncedFolder
|
||||
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun canExitEarly(changedFiles: Array<String>?, syncedFolderID: Long): Boolean {
|
||||
// If we are in power save mode better to postpone scan and upload
|
||||
|
@ -81,18 +80,21 @@ class FilesSyncWork(
|
|||
// or sync worker already running and no changed files to be processed
|
||||
val alreadyRunning = backgroundJobManager.bothFilesSyncJobsRunning(syncedFolderID)
|
||||
if (alreadyRunning && changedFiles.isNullOrEmpty()) {
|
||||
Log_OC.d(TAG, "File-sync kill worker since another instance of the worker ($syncedFolderID) seems to be running already!")
|
||||
Log_OC.d(
|
||||
TAG,
|
||||
"File-sync kill worker since another instance of the worker " +
|
||||
"($syncedFolderID) seems to be running already!"
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
val syncedFolderTmp = syncedFolderProvider.getSyncedFolderByID(syncedFolderID)
|
||||
if (syncedFolderTmp == null || !syncedFolderTmp.isEnabled || !syncedFolderTmp.isExisting) {
|
||||
Log_OC.d(TAG, "File-sync kill worker since syncedFolder (${syncedFolderID}) is not enabled!")
|
||||
Log_OC.d(TAG, "File-sync kill worker since syncedFolder ($syncedFolderID) is not enabled!")
|
||||
return true
|
||||
}
|
||||
syncedFolder = syncedFolderTmp
|
||||
|
||||
|
||||
if (syncedFolder.isChargingOnly &&
|
||||
!powerManagementService.battery.isCharging &&
|
||||
!powerManagementService.battery.isFull
|
||||
|
@ -109,7 +111,7 @@ class FilesSyncWork(
|
|||
val syncFolderId = inputData.getLong(SYNCED_FOLDER_ID, -1)
|
||||
val changedFiles = inputData.getStringArray(CHANGED_FILES)
|
||||
|
||||
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class)+"_"+syncFolderId)
|
||||
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class) + "_" + syncFolderId)
|
||||
Log_OC.d(TAG, "File-sync worker started for folder ID: $syncFolderId")
|
||||
|
||||
if (canExitEarly(changedFiles, syncFolderId)) {
|
||||
|
@ -128,7 +130,11 @@ class FilesSyncWork(
|
|||
)
|
||||
|
||||
// Get changed files from ContentObserverWork (only images and videos) or by scanning filesystem
|
||||
Log_OC.d(TAG, "File-sync worker (${syncedFolder.remotePath}) changed files from observer: " + changedFiles.contentToString())
|
||||
Log_OC.d(
|
||||
TAG,
|
||||
"File-sync worker (${syncedFolder.remotePath}) changed files from observer: " +
|
||||
changedFiles.contentToString()
|
||||
)
|
||||
collectChangedFiles(changedFiles)
|
||||
Log_OC.d(TAG, "File-sync worker (${syncedFolder.remotePath}) finished checking files.")
|
||||
|
||||
|
|
|
@ -571,7 +571,7 @@ class SyncedFoldersActivity :
|
|||
}
|
||||
}
|
||||
if (syncedFolderDisplayItem.isEnabled) {
|
||||
backgroundJobManager.startImmediateFilesSyncJob(syncedFolderDisplayItem.id ,overridePowerSaving = false)
|
||||
backgroundJobManager.startImmediateFilesSyncJob(syncedFolderDisplayItem.id, overridePowerSaving = false)
|
||||
showBatteryOptimizationInfo()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue