From de1dcfe93af98b7eba756d1e7c25bd4e35e794ad Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:46:35 +0200 Subject: [PATCH] Refactoring and minor changes Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../client/jobs/upload/FileUploadWorker.kt | 2 +- .../android/operations/UploadFileOperation.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index 5c8d67161f..34caee5040 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -235,7 +235,7 @@ class FileUploadWorker( } private fun cleanupUploadProcess(result: RemoteOperationResult, operation: UploadFileOperation) { - if (operation.originalStoragePath.contains(operation.uploadedFilename)) { + if (operation.decryptedRemotePath == operation.uploadedDecyptedRemotePath) { // TODO // This is not ideal fix. When uploading file to the encrypted folder server returns 404 FILE_NOT_FOUND // However file upload successfully completed. This fix mimic success, if upload successfully completed with diff --git a/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java index c36c69f5b9..525770985d 100644 --- a/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/UploadFileOperation.java @@ -759,6 +759,10 @@ public class UploadFileOperation extends SyncOperation { result = new RemoteOperationResult(ResultCode.UNKNOWN_ERROR); } + if (result.isSuccess()) { + setUploadedDecyptedRemotePath(mFile.getDecryptedRemotePath()); + } + logResult(result, mFile.getStoragePath(), mFile.getRemotePath()); // unlock must be done always @@ -998,21 +1002,18 @@ public class UploadFileOperation extends SyncOperation { } } - private String uploadedFilename; + private String uploadedDecyptedRemotePath; - public String getUploadedFilename(){ - return uploadedFilename; + public String getUploadedDecyptedRemotePath(){ + return uploadedDecyptedRemotePath; } - public void setUploadedFilename(String uploadedFilename){ - this.uploadedFilename = uploadedFilename; + public void setUploadedDecyptedRemotePath(String uploadedDecyptedRemotePath){ + this.uploadedDecyptedRemotePath = uploadedDecyptedRemotePath; } private void logResult(RemoteOperationResult result, String sourcePath, String targetPath) { if (result.isSuccess()) { - String filename = sourcePath.substring(sourcePath.lastIndexOf('/') + 1); - setUploadedFilename(filename); - Log_OC.i(TAG, "Upload of " + sourcePath + " to " + targetPath + ": " + result.getLogMessage()); } else { if (result.getException() != null) {