Skip to content

Commit 569314c

Browse files
committed
fix: Use actual file modification time for local change detection
1 parent 301e6a6 commit 569314c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

opencloudApp/src/main/java/eu/opencloud/android/usecases/synchronization/SynchronizeFileUseCase.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ class SynchronizeFileUseCase(
7878
val uuid = requestForDownload(accountName = accountName, ocFile = fileToSynchronize)
7979
SyncType.DownloadEnqueued(uuid)
8080
} else {
81-
// 3. Check if file has changed locally
82-
val changedLocally = fileToSynchronize.localModificationTimestamp > fileToSynchronize.lastSyncDateForData!!
83-
Timber.i("Local file modification timestamp :${fileToSynchronize.localModificationTimestamp}" +
81+
// 3. Check if file has changed locally by reading ACTUAL file timestamp from filesystem
82+
val localFile = File(fileToSynchronize.storagePath!!)
83+
val actualFileModificationTime = localFile.lastModified()
84+
val changedLocally = actualFileModificationTime > fileToSynchronize.lastSyncDateForData!!
85+
Timber.i("Actual file modification timestamp :$actualFileModificationTime" +
8486
" and last sync date for data :${fileToSynchronize.lastSyncDateForData}")
8587
Timber.i("So it has changed locally: $changedLocally")
8688

0 commit comments

Comments
 (0)