From 866f9b077384a3914e92e25928c82d66b58a806c Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 4 Oct 2023 17:56:25 +0200 Subject: [PATCH 1/4] fix problem when checking timestamp from remote file --- .../java/foundation/e/drive/contentScanner/FileDiffUtils.kt | 2 +- .../foundation/e/drive/operations/DownloadFileOperation.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt b/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt index e5a3f498..7a40387e 100644 --- a/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt +++ b/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt @@ -24,7 +24,7 @@ object FileDiffUtils { @JvmStatic fun getActionForFileDiff(remoteFile: RemoteFile, fileState: SyncedFileState): Action { if (!hasEtagChanged(remoteFile, fileState)) { - if (isCorruptedTimestamp(remoteFile.modifiedTimestamp)) return Action.Upload + if (isCorruptedTimestamp(remoteFile.modifiedTimestamp/1000)) return Action.Upload if (hasAlreadyBeenDownloaded(fileState)) return Action.Skip } diff --git a/app/src/main/java/foundation/e/drive/operations/DownloadFileOperation.java b/app/src/main/java/foundation/e/drive/operations/DownloadFileOperation.java index fcce43f8..103c7ed1 100644 --- a/app/src/main/java/foundation/e/drive/operations/DownloadFileOperation.java +++ b/app/src/main/java/foundation/e/drive/operations/DownloadFileOperation.java @@ -156,7 +156,7 @@ public class DownloadFileOperation extends RemoteOperation { } if (remoteFile.getModifiedTimestamp() < CORRUPTED_TIMESTAMP_IN_SECOND) { - targetFile.setLastModified(remoteFile.getModifiedTimestamp() * 1000); //android uses timestamp in MS + targetFile.setLastModified(remoteFile.getModifiedTimestamp()); } syncedFileState.setLastModified(targetFile.lastModified()); syncedFileState.setLastEtag(remoteFile.getEtag()); -- GitLab From 4d8aaf8db7d0d7f5886dcb12306fb269d8483806 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Wed, 4 Oct 2023 17:56:55 +0200 Subject: [PATCH 2/4] improve logging --- .../foundation/e/drive/services/SynchronizationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java index 80fecd13..11f6c7f0 100644 --- a/app/src/main/java/foundation/e/drive/services/SynchronizationService.java +++ b/app/src/main/java/foundation/e/drive/services/SynchronizationService.java @@ -240,7 +240,7 @@ public class SynchronizationService extends Service implements OnRemoteOperation } if (!canStart(threadIndex) || isPaused()) { - Timber.d("Can't start thread #%s", threadIndex); + Timber.d("Can't start thread #%s, Sync is paused or thread is already running", threadIndex); return; } -- GitLab From 558c767da94a1af4913f1890b66b72d3413168c2 Mon Sep 17 00:00:00 2001 From: vincent Bourgmayer Date: Thu, 5 Oct 2023 10:22:51 +0200 Subject: [PATCH 3/4] fix failing test due to conversion of corrupted timestamp in ms --- .../foundation/e/drive/contentScanner/FileDiffUtilsTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/test/java/foundation/e/drive/contentScanner/FileDiffUtilsTest.kt b/app/src/test/java/foundation/e/drive/contentScanner/FileDiffUtilsTest.kt index 2478e14a..8bae8a20 100644 --- a/app/src/test/java/foundation/e/drive/contentScanner/FileDiffUtilsTest.kt +++ b/app/src/test/java/foundation/e/drive/contentScanner/FileDiffUtilsTest.kt @@ -269,7 +269,7 @@ internal class FileDiffUtilsTest { @Test fun `getActionForFileDiff(RemoteFile) return Upload when remote modifiedTimestamp is corrupted and eTag unchanged`() { val mockedRemoteFile = Mockito.mock(RemoteFile::class.java) - Mockito.`when`(mockedRemoteFile.modifiedTimestamp).thenReturn(4294967295L) + Mockito.`when`(mockedRemoteFile.modifiedTimestamp).thenReturn(4294967295000L) Mockito.`when`(mockedRemoteFile.etag).thenReturn("123456") val mockedFileState = Mockito.mock(SyncedFileState::class.java) Mockito.`when`(mockedFileState.lastEtag).thenReturn("123456") @@ -280,7 +280,7 @@ internal class FileDiffUtilsTest { @Test fun `getActionForFileDiff(RemoteFile) don't return Upload when remote modifiedTimestamp is corrupted but eTag changed`() { val mockedRemoteFile = Mockito.mock(RemoteFile::class.java) - Mockito.`when`(mockedRemoteFile.modifiedTimestamp).thenReturn(4294967295L) + Mockito.`when`(mockedRemoteFile.modifiedTimestamp).thenReturn(4294967295000L) Mockito.`when`(mockedRemoteFile.etag).thenReturn("654321") val mockedFileState = Mockito.mock(SyncedFileState::class.java) Mockito.`when`(mockedFileState.lastEtag).thenReturn("123456789") @@ -309,6 +309,6 @@ internal class FileDiffUtilsTest { fun `isCorruptedTimestamp() return false with timestamp smaller than max of Int32 `() { val corruptedTimestamp = 4294967295L - 1 val resultUnderTest = FileDiffUtils.isCorruptedTimestamp(corruptedTimestamp) - Assert.assertFalse("isCorruptedTimestamp(4294967295L) returned $resultUnderTest instead of false", resultUnderTest) + Assert.assertFalse("isCorruptedTimestamp(4294967295000L) returned $resultUnderTest instead of false", resultUnderTest) } } \ No newline at end of file -- GitLab From 7c266f48e732c2c0c0f2bdd711ea01eb4b61f8ac Mon Sep 17 00:00:00 2001 From: Hasib Prince Date: Thu, 5 Oct 2023 09:09:51 +0000 Subject: [PATCH 4/4] Apply 1 suggestion(s) to 1 file(s) --- .../java/foundation/e/drive/contentScanner/FileDiffUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt b/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt index 7a40387e..273dfe5c 100644 --- a/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt +++ b/app/src/main/java/foundation/e/drive/contentScanner/FileDiffUtils.kt @@ -24,7 +24,7 @@ object FileDiffUtils { @JvmStatic fun getActionForFileDiff(remoteFile: RemoteFile, fileState: SyncedFileState): Action { if (!hasEtagChanged(remoteFile, fileState)) { - if (isCorruptedTimestamp(remoteFile.modifiedTimestamp/1000)) return Action.Upload + if (isCorruptedTimestamp(remoteFile.modifiedTimestamp / 1000)) return Action.Upload if (hasAlreadyBeenDownloaded(fileState)) return Action.Skip } -- GitLab