Skip to content

Commit 317a04b

Browse files
committed
Kotlin conversion of UploadFileOperation
Signed-off-by: Hannes Achleitner <hannes.software@gmx.at>
1 parent e57afed commit 317a04b

12 files changed

Lines changed: 1910 additions & 1838 deletions

File tree

.idea/codeStyles/Project.xml

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import kotlinx.coroutines.withContext
5252
import java.io.File
5353
import java.util.concurrent.ConcurrentHashMap
5454
import kotlin.random.Random
55+
import kotlin.time.Duration.Companion.milliseconds
5556

5657
@Suppress("LongParameterList", "TooGenericExceptionCaught")
5758
class FileUploadWorker(
@@ -250,7 +251,7 @@ class FileUploadWorker(
250251
for ((index, upload) in uploads.withIndex()) {
251252
ensureActive()
252253

253-
delay(retryPolicy.getDelay())
254+
delay(retryPolicy.getDelay().milliseconds)
254255

255256
if (!skipAutoUploadCheck && isBelongToAnySyncedFolder(upload, syncFolderHelper, syncedFolders)) {
256257
Log_OC.d(TAG, "skipping upload, will be handled by AutoUploadWorker: ${upload.localPath}")
@@ -368,7 +369,7 @@ class FileUploadWorker(
368369
result = operation.execute(client)
369370
val task = ThumbnailsCacheManager.ThumbnailGenerationTask(storageManager, user)
370371
val file = File(operation.originalStoragePath)
371-
val remoteId: String? = operation.file.remoteId
372+
val remoteId: String? = operation.file!!.remoteId
372373
task.execute(ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file, remoteId))
373374
fileUploadEventBroadcaster.sendUploadStarted(operation, context)
374375
} catch (e: Exception) {
@@ -387,7 +388,7 @@ class FileUploadWorker(
387388
val showSameFileAlreadyExistsNotification =
388389
inputData.getBoolean(SHOW_SAME_FILE_ALREADY_EXISTS_NOTIFICATION, false)
389390
if (showSameFileAlreadyExistsNotification) {
390-
notificationManager.showSameFileAlreadyExistsNotification(operation.fileName)
391+
notificationManager.showSameFileAlreadyExistsNotification(operation.fileName!!)
391392
}
392393
}
393394
},

app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
9999
setProgress(0, 0, false)
100100
}.build()
101101

102-
showNotification(operation.file.fileId.toInt(), notification)
102+
showNotification(operation.file!!.fileId.toInt(), notification)
103103
}
104104

105105
fun showConnectionErrorNotification() {

app/src/main/java/com/nextcloud/client/jobs/utils/UploadErrorNotificationManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object UploadErrorNotificationManager {
5757
) {
5858
Log_OC.d(TAG, "handle upload result with result code: " + result.code)
5959

60-
if (result.isSuccess || operation.isMissingPermissionThrown) {
60+
if (result.isSuccess || operation.isMissingPermissionThrown()) {
6161
Log_OC.d(TAG, "operation is successful, cancelled or lack of storage permission, notification skipped")
6262
return
6363
}

app/src/main/java/com/owncloud/android/operations/CopyFileOperation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
7070
if (file.isFolder()) {
7171
targetPath = targetParentPath + file.getFileName();
7272
}
73-
targetPath = UploadFileOperation.getNewAvailableRemotePath(client, targetPath, null, false);
73+
targetPath = UploadFileOperation.Companion.getNewAvailableRemotePath(client, targetPath, null, false);
7474

7575
if (file.isFolder()) {
7676
targetPath += OCFile.PATH_SEPARATOR;

app/src/main/java/com/owncloud/android/operations/UploadException.java

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Nextcloud - Android Client
3+
*
4+
* SPDX-FileCopyrightText: 2019 Andy Scherzinger <info@andy-scherzinger.de>
5+
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
6+
*/
7+
package com.owncloud.android.operations
8+
9+
class UploadException : Exception {
10+
11+
constructor(message: String?) : super(message)
12+
13+
companion object {
14+
private const val serialVersionUID = 5931153844211429915L
15+
}
16+
}

0 commit comments

Comments
 (0)