refactor(sync): перевёл журнал на map по пути и убрал цикл debounce-sync

Журнал хранится как словарь path→entry, служебные пути исключены из sync.
Apply пишет файлы без записи в журнал; bootstrap не триггерит sync во время работы.
This commit is contained in:
2026-05-21 22:05:57 +03:00
parent 51e6f40587
commit d0f490a3fd
11 changed files with 275 additions and 153 deletions

View File

@@ -1,5 +1,6 @@
package com.github.nullptroma.wallenc.app.sync
import com.github.nullptroma.wallenc.domain.datatypes.StorageSyncPaths
import com.github.nullptroma.wallenc.domain.interfaces.IVaultsManager
import com.github.nullptroma.wallenc.ui.R
import com.github.nullptroma.wallenc.ui.resources.UiStringResolver
@@ -10,6 +11,7 @@ import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.launch
@@ -35,14 +37,28 @@ class StorageSyncBootstrap @Inject constructor(
}
val triggers = storages.flatMap { storage ->
listOf(
storage.accessor.filesUpdates.map {},
storage.accessor.dirsUpdates.map {},
storage.accessor.filesUpdates
.filter { page ->
page.data.any { file ->
StorageSyncPaths.isSyncableUserPath(file.metaInfo.path)
}
}
.map {},
storage.accessor.dirsUpdates
.filter { page ->
page.data.any { dir ->
StorageSyncPaths.isSyncableUserPath(dir.metaInfo.path)
}
}
.map {},
)
}
merge(*triggers.toTypedArray())
.debounce(DEBOUNCE_AFTER_CHANGE_MS)
.collect {
// RunStorageSyncUseCase.enqueue отбрасывает повтор, пока sync уже в очереди/в работе.
if (syncRunner.syncRunning.value) {
return@collect
}
syncRunner.enqueue(
displayTitle = uiStrings(R.string.task_title_storage_sync_background),
logReason = "debounce",