Skip to content

Commit

Permalink
Update state tracking to also include file backup check
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Dec 18, 2024
1 parent 0106719 commit 9474a8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/src/main/java/com/stevesoltys/seedvault/BackupStateManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.stevesoltys.seedvault.transport.ConfigurableBackupTransportService
import com.stevesoltys.seedvault.worker.AppBackupPruneWorker
import com.stevesoltys.seedvault.worker.AppBackupWorker.Companion.UNIQUE_WORK_NAME
import com.stevesoltys.seedvault.worker.AppCheckerWorker
import com.stevesoltys.seedvault.worker.FileCheckerWorker
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine

Expand All @@ -36,7 +37,7 @@ class BackupStateManager(
) { appBackupRunning, filesBackupRunning, workInfo1 ->
val workInfoState1 = workInfo1.getOrNull(0)?.state
Log.i(
TAG, "appBackupRunning: $appBackupRunning, " +
TAG, "B - appBackupRunning: $appBackupRunning, " +
"filesBackupRunning: $filesBackupRunning, " +
"appBackupWorker: ${workInfoState1?.name}"
)
Expand All @@ -46,15 +47,18 @@ class BackupStateManager(
val isCheckOrPruneRunning: Flow<Boolean> = combine(
flow = workManager.getWorkInfosForUniqueWorkFlow(AppBackupPruneWorker.UNIQUE_WORK_NAME),
flow2 = workManager.getWorkInfosForUniqueWorkFlow(AppCheckerWorker.UNIQUE_WORK_NAME),
) { pruneInfo, checkInfo ->
flow3 = workManager.getWorkInfosForUniqueWorkFlow(FileCheckerWorker.UNIQUE_WORK_NAME),
) { pruneInfo, appCheckInfo, fileCheckInfo ->
val pruneInfoState = pruneInfo.getOrNull(0)?.state
val checkInfoState = checkInfo.getOrNull(0)?.state
val appCheckState = appCheckInfo.getOrNull(0)?.state
val fileCheckState = fileCheckInfo.getOrNull(0)?.state
Log.i(
TAG,
"pruneBackupWorker: ${pruneInfoState?.name}, " +
"appCheckerWorker: ${checkInfoState?.name}"
"C - pruneBackupWorker: ${pruneInfoState?.name}, " +
"appCheckerWorker: ${appCheckState?.name}, " +
"fileCheckerWorker: ${fileCheckState?.name}"
)
pruneInfoState == RUNNING || checkInfoState == RUNNING
pruneInfoState == RUNNING || appCheckState == RUNNING || fileCheckState == RUNNING
}

val isAutoRestoreEnabled: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FileCheckerWorker(

companion object {
private val TAG = FileCheckerWorker::class.simpleName
const val UNIQUE_WORK_NAME = CheckerWorker.UNIQUE_WORK_NAME

fun scheduleNow(
context: Context,
Expand Down

0 comments on commit 9474a8f

Please sign in to comment.