Fix Spotless

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2024-03-21 17:43:22 +01:00 committed by Jonas Mayer
parent b7a5387aea
commit 04d65accb2
3 changed files with 12 additions and 8 deletions

View file

@ -61,8 +61,8 @@ class ContentObserverWork(
private fun checkAndStartFileSyncJob() { private fun checkAndStartFileSyncJob() {
val syncFolders = syncerFolderProvider.countEnabledSyncedFolders() > 0 val syncFolders = syncerFolderProvider.countEnabledSyncedFolders() > 0
if (!powerManagementService.isPowerSavingEnabled && syncFolders) { if (!powerManagementService.isPowerSavingEnabled && syncFolders) {
val changedFiles = mutableListOf<String>(); val changedFiles = mutableListOf<String>()
for (uri in params.triggeredContentUris){ for (uri in params.triggeredContentUris) {
changedFiles.add(uri.toString()) changedFiles.add(uri.toString())
} }
backgroundJobManager.startImmediateFilesSyncJob(false, changedFiles.toTypedArray()) backgroundJobManager.startImmediateFilesSyncJob(false, changedFiles.toTypedArray())

View file

@ -143,7 +143,11 @@ class FilesSyncWork(
(50 + (index.toDouble() / syncedFolders.size.toDouble()) * 50).toInt(), (50 + (index.toDouble() / syncedFolders.size.toDouble()) * 50).toInt(),
changedFiles.isNullOrEmpty() changedFiles.isNullOrEmpty()
) )
if (syncedFolder.isEnabled && (changedFiles.isNullOrEmpty() || MediaFolderType.CUSTOM != syncedFolder.type)) { if (syncedFolder.isEnabled && (
changedFiles.isNullOrEmpty() ||
MediaFolderType.CUSTOM != syncedFolder.type
)
) {
syncFolder( syncFolder(
context, context,
resources, resources,
@ -160,12 +164,13 @@ class FilesSyncWork(
return result return result
} }
private fun collectChangedFiles(changedFiles: Array<String>?){ @Suppress("MagicNumber")
private fun collectChangedFiles(changedFiles: Array<String>?) {
if (!changedFiles.isNullOrEmpty()) { if (!changedFiles.isNullOrEmpty()) {
FilesSyncHelper.insertChangedEntries(syncedFolderProvider,changedFiles) FilesSyncHelper.insertChangedEntries(syncedFolderProvider, changedFiles)
} else { } else {
// Check every file in every synced folder for changes and update filesystemDataProvider database (expensive) // Check every file in every synced folder for changes and update
// Potentially needs a long time so use foreground worker // filesystemDataProvider database (potentially needs a long time so use foreground worker)
updateForegroundWorker(5, true) updateForegroundWorker(5, true)
FilesSyncHelper.insertAllDBEntries(syncedFolderProvider) FilesSyncHelper.insertAllDBEntries(syncedFolderProvider)
updateForegroundWorker(50, true) updateForegroundWorker(50, true)

View file

@ -40,7 +40,6 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.nextcloud.client.core.Clock import com.nextcloud.client.core.Clock
import com.nextcloud.client.device.PowerManagementService import com.nextcloud.client.device.PowerManagementService
import com.nextcloud.client.di.Injectable import com.nextcloud.client.di.Injectable
import com.nextcloud.client.jobs.BackgroundJobManager
import com.nextcloud.client.jobs.MediaFoldersDetectionWork import com.nextcloud.client.jobs.MediaFoldersDetectionWork
import com.nextcloud.client.jobs.NotificationWork import com.nextcloud.client.jobs.NotificationWork
import com.nextcloud.client.jobs.upload.FileUploadWorker import com.nextcloud.client.jobs.upload.FileUploadWorker