Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class ContactsBackupIT : AbstractOnServerIT() {
fail("ocFile.storagePath cannot be null")
}

assertTrue(DownloadFileOperation(user, ocFile, targetContext).execute(client).isSuccess)
assertTrue(DownloadFileOperation(user, ocFile!!, targetContext).execute(client).isSuccess)

val file = ocFile?.storagePath?.let { File(it) }
val file = ocFile.storagePath?.let { File(it) }
if (file == null) {
fail("file cannot be null")
}
Expand Down
11 changes: 9 additions & 2 deletions app/src/androidTest/java/com/owncloud/android/DownloadIT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.owncloud.android.operations.RemoveFileOperation
import com.owncloud.android.utils.FileStorageUtils
import org.junit.After
import org.junit.Assert
import org.junit.Assert.fail
import org.junit.Test
import kotlin.io.path.Path
import kotlin.io.path.exists
Expand Down Expand Up @@ -72,11 +73,17 @@ class DownloadIT : AbstractOnServerIT() {
var file1 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt")
var file2 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty2.txt")

val operation1 = DownloadFileOperation(user, file1, targetContext)
if (file1 == null) {
fail("file 1 cannot be null")
}
val operation1 = DownloadFileOperation(user, file1!!, targetContext)
val operation1Result = operation1.execute(client)
Assert.assertTrue(operation1Result.isSuccess)

val operation2 = DownloadFileOperation(user, file2, targetContext)
if (file2 == null) {
fail("file 2 cannot be null")
}
val operation2 = DownloadFileOperation(user, file2!!, targetContext)
val operation2Result = operation2.execute(client)
Assert.assertTrue(operation2Result.isSuccess)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class DownloadTask(
lastSyncDateForProperties = syncDate
lastSyncDateForData = syncDate
isUpdateThumbnailNeeded = true
modificationTimestamp = op.modificationTimestamp
modificationTimestampAtLastSyncForData = op.modificationTimestamp
modificationTimestamp = op.getModificationTimestamp()
modificationTimestampAtLastSyncForData = op.getModificationTimestamp()
etag = op.etag
mimeType = op.mimeType
storagePath = op.savePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class FileDownloadHelper {
lastSyncDateForProperties = syncDate
lastSyncDateForData = syncDate
isUpdateThumbnailNeeded = true
modificationTimestamp = currentDownload?.modificationTimestamp ?: 0L
modificationTimestampAtLastSyncForData = currentDownload?.modificationTimestamp ?: 0L
modificationTimestamp = currentDownload?.getModificationTimestamp() ?: 0L
modificationTimestampAtLastSyncForData = currentDownload?.getModificationTimestamp() ?: 0L
etag = currentDownload?.etag
mimeType = currentDownload?.mimeType
storagePath = currentDownload?.savePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ class FileDownloadWorker(

val requestedDownloads: AbstractList<String> = Vector()

val user = user ?: run {
Log_OC.e(TAG, "user cannot be null")
return requestedDownloads
}

return try {
files.forEach { file ->
val operation = DownloadFileOperation(
Expand All @@ -190,7 +195,7 @@ class FileDownloadWorker(
operation.addDownloadDataTransferProgressListener(this)
operation.addDownloadDataTransferProgressListener(downloadProgressListener)
val (downloadKey, _) = pendingDownloads.putIfAbsent(
user?.accountName,
user.accountName,
file.remotePath,
operation
) ?: Pair(null, null)
Expand Down
Loading
Loading