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 e5a3f49846f988b30350b8bd9ce902b555925519..273dfe5c7e5d6a2e0798dc54ed480ea736cc7dd5 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 fcce43f8163a893e7db3151b92e9a3d7e6226467..103c7ed18c986657795416e535dd6c7ea2f75c63 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()); 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 80fecd13e7feb4e1bd76123acdf5585b34abdacd..11f6c7f0083f80b049ae7b5165c1987e89b0437b 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; } 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 2478e14a8707691dc21e6ece80c0befcb0e983c5..8bae8a20bdb1d840fe044c581c88a25a2c76446a 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