From e8246d2bbf7123315457de04042b8e7f9862e32c Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Thu, 11 Jun 2026 16:33:38 +0200 Subject: [PATCH] fix(folder-refresh-scheduler): updating Signed-off-by: alperozturk96 --- .../operations/FolderRefreshScheduler.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/operations/FolderRefreshScheduler.kt b/app/src/main/java/com/owncloud/android/operations/FolderRefreshScheduler.kt index 958db34e5a02..c6106a98dbb5 100644 --- a/app/src/main/java/com/owncloud/android/operations/FolderRefreshScheduler.kt +++ b/app/src/main/java/com/owncloud/android/operations/FolderRefreshScheduler.kt @@ -8,16 +8,19 @@ package com.owncloud.android.operations import androidx.lifecycle.lifecycleScope +import com.owncloud.android.datamodel.OCFile import com.owncloud.android.lib.common.operations.RemoteOperationResult import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.files.CheckEtagRemoteOperation import com.owncloud.android.ui.activity.FileDisplayActivity +import com.owncloud.android.ui.fragment.OCFileListFragment import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import kotlin.time.Duration.Companion.milliseconds class FolderRefreshScheduler(private val activity: FileDisplayActivity) { companion object { @@ -32,7 +35,7 @@ class FolderRefreshScheduler(private val activity: FileDisplayActivity) { job = activity.lifecycleScope.launch { while (isActive) { - delay(ETAG_POLL_INTERVAL_MS) + delay(ETAG_POLL_INTERVAL_MS.milliseconds) checkAndRefreshIfETagChanged() } } @@ -53,9 +56,9 @@ class FolderRefreshScheduler(private val activity: FileDisplayActivity) { return } - val currentDir = activity.getCurrentDir() - if (currentDir == null) { - Log_OC.w(TAG, "current directory is null") + val fragment = (activity.leftFragment) + if (fragment !is OCFileListFragment) { + Log_OC.w(TAG, "OCFileListFragment not active") return } @@ -65,6 +68,13 @@ class FolderRefreshScheduler(private val activity: FileDisplayActivity) { return } + val currentDir = + activity.getCurrentDir() ?: activity.storageManager.getFileByDecryptedRemotePath(OCFile.ROOT_PATH) + if (currentDir == null) { + Log_OC.w(TAG, "current directory is null") + return + } + val localEtag = currentDir.etag ?: "" Log_OC.d(TAG, "eTag poll → checking '${currentDir.remotePath}' (local eTag='$localEtag')")