Files
SyncFlow/app/src/main/kotlin/com/syncflow/data/db/SyncPairDao.kt
T
amir c60eb8d27b
Build & Release APK / build (push) Has been cancelled
v1.0.63: live sync progress counters, pause/resume, .gitignore fix
- SyncEngine: accepts onProgress callback — emits uploaded/downloaded/
  deleted/bytes counts atomically as each file completes
- SyncWorker: streams progress to WorkManager data so the UI can poll
  it live; reports per-run counters in the completion notification;
  adds pause/resume support
- HomeViewModel/PairDetailViewModel: subscribe to live WorkManager
  progress and surface it via SyncProgress state
- SyncPairEntity/SyncPairDao/SyncDatabase: persist last-run counters
  (uploaded, downloaded, deleted, bytesTransferred) in the DB with a
  Room migration (v3→v4)
- AppModule: provides WorkManager as an injectable singleton
- .gitignore: add .kotlin/ to exclude compiler session files

Security: no new issues — all logging via Timber (debug-only), DB
queries use Room parameterized API, file sharing via FileProvider.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 20:07:25 +00:00

38 lines
1.4 KiB
Kotlin

package com.syncflow.data.db
import androidx.room.*
import com.syncflow.data.db.entities.SyncPairEntity
import com.syncflow.domain.model.SyncStatus
import kotlinx.coroutines.flow.Flow
import java.time.Instant
@Dao
interface SyncPairDao {
@Query("SELECT * FROM sync_pairs ORDER BY name")
fun observeAll(): Flow<List<SyncPairEntity>>
@Query("SELECT * FROM sync_pairs WHERE isEnabled = 1")
suspend fun getEnabled(): List<SyncPairEntity>
@Query("SELECT * FROM sync_pairs WHERE id = :id")
suspend fun getById(id: Long): SyncPairEntity?
@Query("SELECT * FROM sync_pairs WHERE id = :id")
fun observeById(id: Long): Flow<SyncPairEntity?>
@Insert(onConflict = OnConflictStrategy.ABORT)
suspend fun insert(entity: SyncPairEntity): Long
@Update
suspend fun update(entity: SyncPairEntity)
@Delete
suspend fun delete(entity: SyncPairEntity)
@Query("UPDATE sync_pairs SET lastSyncAt = :at, lastSyncResult = :result, pendingConflicts = :conflicts, lastSyncUploaded = :uploaded, lastSyncDownloaded = :downloaded, lastSyncDeleted = :deleted, lastSyncBytesTransferred = :bytes WHERE id = :id")
suspend fun updateSyncResult(id: Long, at: Instant, result: SyncStatus, conflicts: Int, uploaded: Int, downloaded: Int, deleted: Int, bytes: Long)
@Query("UPDATE sync_pairs SET lastSyncResult = :status WHERE id = :id")
suspend fun updateStatus(id: Long, status: SyncStatus)
}