Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}
}
Expand All @@ -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
}

Expand All @@ -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')")
Expand Down
Loading