v1.0.28: fix sync rewrite/delete loop, Avast-inspired icon
Sync loop root-cause fixes (three independent bugs): 1. Folder change clears stale file states (AddPairViewModel): when localPath or remotePath changes on an existing pair, all SyncFileStateEntity records are wiped. Previously those stale records caused every sync to attempt DELETE_REMOTE on the old folder's files and to treat all new-folder files as changed — causing both the "deleting 32 files" loop and rewrites on every run. 2. Download stores null localModifiedAt (SyncEngine): SAF document cursors can return a stale mtime immediately after a write. Storing null forces the SKIP reconciliation pass on the next sync to read the actual walkFiles cursor value, breaking the download->changed-> download loop caused by mtime inconsistency. 3. Second-precision mtime comparison (syncDecide): WebDAV RFC-1123 has 1-second precision; FAT32 has 2-second precision. Comparing at millisecond level caused phantom "changed" detections after syncing to/from these systems. Now uses epochSecond for both local and remote. Icon: three bold teal/red/yellow teardrop streaks (Avast palette) flying into a white cloud centre, on dark charcoal background. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -126,7 +126,9 @@ class SyncEngine @Inject constructor(
|
|||||||
logEvent(pair.id, SyncEventType.FILE_DOWNLOADED, rel, null, bytes)
|
logEvent(pair.id, SyncEventType.FILE_DOWNLOADED, rel, null, bytes)
|
||||||
FileOutcome(downloaded = 1, bytesTransferred = bytes,
|
FileOutcome(downloaded = 1, bytesTransferred = bytes,
|
||||||
newState = buildState(pair.id, rel,
|
newState = buildState(pair.id, rel,
|
||||||
LocalFileInfo(rel, remote!!.sizeBytes, localMtime), remoteAfterTransfer = remote))
|
LocalFileInfo(rel, remote!!.sizeBytes, localMtime),
|
||||||
|
remoteAfterTransfer = remote,
|
||||||
|
storeLocalMtime = false))
|
||||||
}
|
}
|
||||||
SyncDecision.DELETE_LOCAL -> {
|
SyncDecision.DELETE_LOCAL -> {
|
||||||
accessor.delete(rel)
|
accessor.delete(rel)
|
||||||
@@ -203,10 +205,13 @@ class SyncEngine @Inject constructor(
|
|||||||
rel: String,
|
rel: String,
|
||||||
local: LocalFileInfo?,
|
local: LocalFileInfo?,
|
||||||
remoteAfterTransfer: RemoteFile?,
|
remoteAfterTransfer: RemoteFile?,
|
||||||
|
storeLocalMtime: Boolean = true,
|
||||||
) = SyncFileStateEntity(
|
) = SyncFileStateEntity(
|
||||||
syncPairId = pairId,
|
syncPairId = pairId,
|
||||||
relativePath = rel,
|
relativePath = rel,
|
||||||
localModifiedAt = local?.lastModifiedMs?.let { Instant.ofEpochMilli(it) },
|
// When storeLocalMtime=false, leave localModifiedAt null so the SKIP reconciliation
|
||||||
|
// pass on the next sync reads it from the walkFiles cursor (avoids SAF stale-mtime loops).
|
||||||
|
localModifiedAt = if (storeLocalMtime) local?.lastModifiedMs?.let { Instant.ofEpochMilli(it) } else null,
|
||||||
localSizeBytes = local?.sizeBytes ?: 0L,
|
localSizeBytes = local?.sizeBytes ?: 0L,
|
||||||
localHash = null,
|
localHash = null,
|
||||||
remoteModifiedAt = remoteAfterTransfer?.modifiedAt,
|
remoteModifiedAt = remoteAfterTransfer?.modifiedAt,
|
||||||
@@ -236,12 +241,16 @@ internal fun syncDecide(
|
|||||||
|
|
||||||
// Treat null known timestamps as "not yet recorded" — don't treat as changed.
|
// Treat null known timestamps as "not yet recorded" — don't treat as changed.
|
||||||
// The SKIP reconciliation pass will fill them in on the next sync.
|
// The SKIP reconciliation pass will fill them in on the next sync.
|
||||||
|
// Use second-precision for both sides: FAT32 has 2-second mtime resolution, WebDAV
|
||||||
|
// RFC-1123 has 1-second resolution, so millisecond comparison causes phantom "changed"
|
||||||
|
// detections and rewrite loops after a fresh download/upload.
|
||||||
val localChanged = known == null ||
|
val localChanged = known == null ||
|
||||||
(localExists && known.localModifiedAt != null &&
|
(localExists && known.localModifiedAt != null &&
|
||||||
local!!.lastModifiedMs != known.localModifiedAt.toEpochMilli())
|
local!!.lastModifiedMs / 1000 != known.localModifiedAt.epochSecond)
|
||||||
val remoteChanged = known == null ||
|
val remoteChanged = known == null ||
|
||||||
(remoteExists && known.remoteModifiedAt != null &&
|
(remoteExists && known.remoteModifiedAt != null &&
|
||||||
(remote!!.etag != known.remoteEtag || remote.modifiedAt != known.remoteModifiedAt))
|
(remote!!.etag != known.remoteEtag ||
|
||||||
|
remote.modifiedAt.epochSecond != known.remoteModifiedAt.epochSecond))
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
!localExists && !remoteExists -> SyncDecision.SKIP
|
!localExists && !remoteExists -> SyncDecision.SKIP
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.lifecycle.SavedStateHandle
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.syncflow.data.db.CloudAccountDao
|
import com.syncflow.data.db.CloudAccountDao
|
||||||
|
import com.syncflow.data.db.SyncFileStateDao
|
||||||
import com.syncflow.data.db.SyncPairDao
|
import com.syncflow.data.db.SyncPairDao
|
||||||
import com.syncflow.data.db.entities.CloudAccountEntity
|
import com.syncflow.data.db.entities.CloudAccountEntity
|
||||||
import com.syncflow.data.db.entities.SyncPairEntity
|
import com.syncflow.data.db.entities.SyncPairEntity
|
||||||
@@ -58,6 +59,7 @@ data class AddPairUiState(
|
|||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class AddPairViewModel @Inject constructor(
|
class AddPairViewModel @Inject constructor(
|
||||||
private val syncPairDao: SyncPairDao,
|
private val syncPairDao: SyncPairDao,
|
||||||
|
private val fileStateDao: SyncFileStateDao,
|
||||||
private val accountDao: CloudAccountDao,
|
private val accountDao: CloudAccountDao,
|
||||||
@ApplicationContext private val context: Context,
|
@ApplicationContext private val context: Context,
|
||||||
savedState: SavedStateHandle,
|
savedState: SavedStateHandle,
|
||||||
@@ -148,7 +150,20 @@ class AddPairViewModel @Inject constructor(
|
|||||||
notifyOnComplete = s.notifyOnComplete, notifyOnError = s.notifyOnError,
|
notifyOnComplete = s.notifyOnComplete, notifyOnError = s.notifyOnError,
|
||||||
isEnabled = true, lastSyncAt = null, lastSyncResult = SyncStatus.IDLE, pendingConflicts = 0,
|
isEnabled = true, lastSyncAt = null, lastSyncResult = SyncStatus.IDLE, pendingConflicts = 0,
|
||||||
)
|
)
|
||||||
if (editPairId == null) syncPairDao.insert(entity) else syncPairDao.update(entity)
|
if (editPairId == null) {
|
||||||
|
syncPairDao.insert(entity)
|
||||||
|
} else {
|
||||||
|
val existing = syncPairDao.getById(editPairId)
|
||||||
|
syncPairDao.update(entity)
|
||||||
|
// If local or remote folder changed, old file-state records no longer
|
||||||
|
// correspond to any real path — wipe them so the next sync starts fresh
|
||||||
|
// instead of trying to delete/re-upload stale paths.
|
||||||
|
if (existing != null &&
|
||||||
|
(existing.localPath != entity.localPath || existing.remotePath != entity.remotePath)
|
||||||
|
) {
|
||||||
|
fileStateDao.deleteForPair(editPairId)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
if (s.scheduleType == ScheduleType.ON_CHANGE) FileWatchService.start(context)
|
if (s.scheduleType == ScheduleType.ON_CHANGE) FileWatchService.start(context)
|
||||||
|
|||||||
@@ -6,14 +6,19 @@
|
|||||||
android:viewportWidth="108"
|
android:viewportWidth="108"
|
||||||
android:viewportHeight="108">
|
android:viewportHeight="108">
|
||||||
|
|
||||||
<!-- Deep purple-black base, matching the knot reference icon's dark background -->
|
<!-- Dark charcoal background, matching Avast-style dark icon bg -->
|
||||||
<path android:pathData="M0,0 H108 V108 H0 Z">
|
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||||
|
android:fillColor="#1F1F2E"/>
|
||||||
|
|
||||||
|
<!-- Very subtle inner glow -->
|
||||||
|
<path android:pathData="M0,0 H108 V108 H0 Z"
|
||||||
|
android:fillAlpha="0.25">
|
||||||
<aapt:attr name="android:fillColor">
|
<aapt:attr name="android:fillColor">
|
||||||
<gradient android:type="radial"
|
<gradient android:type="radial"
|
||||||
android:gradientRadius="76"
|
android:gradientRadius="60"
|
||||||
android:centerX="54" android:centerY="44"
|
android:centerX="54" android:centerY="50"
|
||||||
android:startColor="#1E1628"
|
android:startColor="#3D3A50"
|
||||||
android:endColor="#080610"/>
|
android:endColor="#00000000"/>
|
||||||
</aapt:attr>
|
</aapt:attr>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
SyncFlow icon foreground (108x108dp, safe zone 72dp centred at 54,54).
|
SyncFlow icon foreground.
|
||||||
|
Design: three bold teardrop "speed streak" shapes in Avast color palette
|
||||||
|
(teal, red, yellow) converging on a white cloud in the centre.
|
||||||
|
Each teardrop has a pointed tail (far from cloud) and a wide rounded head
|
||||||
|
(near the cloud), like motion streaks flying into the sync point.
|
||||||
|
|
||||||
Design: two thick tube-style sync arcs that form a circular refresh symbol,
|
Safe zone: 18-90dp band. Cloud centred at (54, 55).
|
||||||
inspired by the braided knot icon's color palette:
|
|
||||||
Arc 1 (left side, CW): coral #E8665A -> orange #E8A040
|
|
||||||
Arc 2 (right side, CW): steel blue #4A7FD4 -> purple #7B5EA7
|
|
||||||
Each arc has a thin inner highlight to give a 3D glossy tube look.
|
|
||||||
|
|
||||||
Geometry: circle centred at (54,54), radius 27.
|
|
||||||
Arc 1: 100 deg to 260 deg CW (160 deg, through west/left)
|
|
||||||
start (49.31, 80.59) end (49.31, 27.41)
|
|
||||||
Arc 2: 280 deg to 80 deg CW (160 deg, through east/right)
|
|
||||||
start (58.69, 27.41) end (58.69, 80.59)
|
|
||||||
20-degree gaps at top (~260-280) and bottom (~80-100).
|
|
||||||
|
|
||||||
Highlights at r=23 (inner edge):
|
|
||||||
Arc 1 highlight: (49.99, 76.64) to (49.99, 31.36)
|
|
||||||
Arc 2 highlight: (58.01, 31.36) to (58.01, 76.64)
|
|
||||||
-->
|
-->
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:aapt="http://schemas.android.com/aapt"
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
@@ -26,74 +15,88 @@
|
|||||||
android:viewportWidth="108"
|
android:viewportWidth="108"
|
||||||
android:viewportHeight="108">
|
android:viewportHeight="108">
|
||||||
|
|
||||||
<!-- Arc 1 shadow (offset slightly down-right for depth) -->
|
<!-- SHADOW layer under teardrops for depth -->
|
||||||
<path
|
<path
|
||||||
android:pathData="M 50.31,82.59 A 27,27 0 0,1 50.31,29.41"
|
android:pathData="M 54,28 C 42,28 30,36 32,50 C 22,55 22,70 34,72 L 74,72 C 84,72 88,62 82,55 C 86,43 76,33 66,35 C 62,30 58,28 54,28 Z"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#000000"
|
||||||
android:strokeWidth="9"
|
android:fillAlpha="0.20"
|
||||||
android:strokeLineCap="round"
|
android:translateY="2.5"/>
|
||||||
android:strokeColor="#44000000"/>
|
|
||||||
|
|
||||||
<!-- Arc 2 shadow -->
|
<!-- TEAL teardrop: enters from upper-left, tail at (22,22), head near cloud top-left -->
|
||||||
|
<!-- Teardrop shape: pointed at tail, fat elliptical head, rotated ~45 deg into centre -->
|
||||||
<path
|
<path
|
||||||
android:pathData="M 59.69,29.41 A 27,27 0 0,1 59.69,82.59"
|
android:pathData="M 35.5,26.5
|
||||||
android:fillColor="#00000000"
|
C 30,21 22,22 22,22
|
||||||
android:strokeWidth="9"
|
C 22,22 27,30 32.5,35.5
|
||||||
android:strokeLineCap="round"
|
C 36,38 40,40 43,42
|
||||||
android:strokeColor="#44000000"/>
|
C 40,39 36,32 35.5,26.5 Z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
<!-- Arc 1: left side, coral to orange -->
|
|
||||||
<path
|
|
||||||
android:pathData="M 49.31,80.59 A 27,27 0 0,1 49.31,27.41"
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:strokeWidth="9"
|
|
||||||
android:strokeLineCap="round">
|
|
||||||
<aapt:attr name="android:strokeColor">
|
|
||||||
<gradient android:type="linear"
|
<gradient android:type="linear"
|
||||||
android:startX="49.31" android:startY="80.59"
|
android:startX="22" android:startY="22"
|
||||||
android:endX="49.31" android:endY="27.41"
|
android:endX="43" android:endY="42"
|
||||||
android:startColor="#E8665A"
|
android:startColor="#00BFA5"
|
||||||
android:endColor="#E8A040"/>
|
android:endColor="#26D6C0"/>
|
||||||
</aapt:attr>
|
</aapt:attr>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<!-- Arc 2: right side, blue to purple -->
|
<!-- RED teardrop: enters from upper-right, tail at (86,22), head near cloud top-right -->
|
||||||
<path
|
<path
|
||||||
android:pathData="M 58.69,27.41 A 27,27 0 0,1 58.69,80.59"
|
android:pathData="M 72.5,26.5
|
||||||
android:fillColor="#00000000"
|
C 78,21 86,22 86,22
|
||||||
android:strokeWidth="9"
|
C 86,22 81,30 75.5,35.5
|
||||||
android:strokeLineCap="round">
|
C 72,38 68,40 65,42
|
||||||
<aapt:attr name="android:strokeColor">
|
C 68,39 72,32 72.5,26.5 Z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
<gradient android:type="linear"
|
<gradient android:type="linear"
|
||||||
android:startX="58.69" android:startY="27.41"
|
android:startX="86" android:startY="22"
|
||||||
android:endX="58.69" android:endY="80.59"
|
android:endX="65" android:endY="42"
|
||||||
android:startColor="#4A7FD4"
|
android:startColor="#E53935"
|
||||||
android:endColor="#7B5EA7"/>
|
android:endColor="#EF6558"/>
|
||||||
</aapt:attr>
|
</aapt:attr>
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<!-- Arc 1 inner highlight (glossy tube sheen) -->
|
<!-- YELLOW teardrop: enters from bottom-centre, tail at (54,88), head near cloud base -->
|
||||||
<path
|
<path
|
||||||
android:pathData="M 49.99,76.64 A 23,23 0 0,1 49.99,31.36"
|
android:pathData="M 48,75
|
||||||
android:fillColor="#00000000"
|
C 45,82 47,88 54,88
|
||||||
android:strokeWidth="2.5"
|
C 61,88 63,82 60,75
|
||||||
android:strokeLineCap="round"
|
C 58,71 56,68 54,66
|
||||||
android:strokeColor="#55FFC8B0"/>
|
C 52,68 50,71 48,75 Z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient android:type="linear"
|
||||||
|
android:startX="54" android:startY="88"
|
||||||
|
android:endX="54" android:endY="66"
|
||||||
|
android:startColor="#F9A825"
|
||||||
|
android:endColor="#FFD740"/>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
|
||||||
<!-- Arc 2 inner highlight -->
|
<!-- CLOUD body (white, centred at 54,50) -->
|
||||||
<path
|
<path
|
||||||
android:pathData="M 58.01,31.36 A 23,23 0 0,1 58.01,76.64"
|
android:pathData="
|
||||||
|
M 36,62
|
||||||
|
A 9,9 0 0,1 36,44
|
||||||
|
A 9,9 0 0,1 45,36
|
||||||
|
A 12,12 0 0,1 66,37
|
||||||
|
A 8,8 0 0,1 74,48
|
||||||
|
A 8,8 0 0,1 68,62
|
||||||
|
Z"
|
||||||
|
android:fillColor="#FFFFFF"/>
|
||||||
|
|
||||||
|
<!-- Teal highlight on cloud top-left edge -->
|
||||||
|
<path
|
||||||
|
android:pathData="M 36,53 A 9,9 0 0,1 41,38"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeWidth="2.5"
|
android:strokeWidth="2"
|
||||||
android:strokeLineCap="round"
|
android:strokeLineCap="round"
|
||||||
android:strokeColor="#55B0C8FF"/>
|
android:strokeColor="#4000BFA5"/>
|
||||||
|
|
||||||
<!-- Arrowhead at end of Arc 1 (260 deg, top-left area, pointing right-up) -->
|
<!-- Red highlight on cloud top-right edge -->
|
||||||
<path android:pathData="M 42.13,32.74 L 49.31,27.41 L 40.73,24.86 Z"
|
<path
|
||||||
android:fillColor="#E8A040"/>
|
android:pathData="M 63,37 A 8,8 0 0,1 73,48"
|
||||||
|
android:fillColor="#00000000"
|
||||||
<!-- Arrowhead at end of Arc 2 (80 deg, bottom-right area, pointing left-down) -->
|
android:strokeWidth="2"
|
||||||
<path android:pathData="M 67.27,83.14 L 58.69,80.59 L 65.87,75.26 Z"
|
android:strokeLineCap="round"
|
||||||
android:fillColor="#7B5EA7"/>
|
android:strokeColor="#40E53935"/>
|
||||||
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
VERSION_NAME=1.0.27
|
VERSION_NAME=1.0.28
|
||||||
VERSION_CODE=28
|
VERSION_CODE=29
|
||||||
|
|||||||
Reference in New Issue
Block a user