From e7da3ede5e4771eb04048e0bd71e525a99390245 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Wed, 22 Feb 2017 15:20:32 +0100 Subject: [PATCH] Revert "Try to fix changes between upload behaviour" This reverts commit c61ad342e462ebba43a4022d4214ed2bfe13cb6f. --- .../operations/UploadFileOperation.java | 55 ++++++++----------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java index 4721bbb560..33e6f42f43 100644 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@ -76,8 +76,6 @@ public class UploadFileOperation extends SyncOperation { public static final int CREATED_AS_INSTANT_PICTURE = 1; public static final int CREATED_AS_INSTANT_VIDEO = 2; - private String expectedPath; - public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) { // MIME type @@ -348,7 +346,7 @@ public class UploadFileOperation extends SyncOperation { throw new OperationCancelledException(); } - expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile); + String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile); expectedFile = new File(expectedPath); /// copy the file locally before uploading @@ -393,7 +391,28 @@ public class UploadFileOperation extends SyncOperation { /// move local temporal file or original file to its corresponding // location in the ownCloud local folder if (result.isSuccess()) { + if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) { + String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath(); + if (mOriginalStoragePath.equals(temporalPath)) { + // delete local file is was pre-copied in temporary folder (see .ui.helpers.UriUploader) + temporalFile = new File(temporalPath); + temporalFile.delete(); + } + mFile.setStoragePath(""); + } else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_DELETE) { + originalFile.delete(); + } else { + mFile.setStoragePath(expectedPath); + + if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY + move(temporalFile, expectedFile); + } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE + move(originalFile, expectedFile); + getStorageManager().deleteFileInMediaScan(originalFile.getAbsolutePath()); + } + FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath()); + } } else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) { result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); @@ -433,36 +452,6 @@ public class UploadFileOperation extends SyncOperation { if (result.isSuccess()) { saveUploadedFile(client); - if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) { - String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath(); - if (mOriginalStoragePath.equals(temporalPath)) { - // delete local file is was pre-copied in temporary folder (see .ui.helpers.UriUploader) - temporalFile = new File(temporalPath); - temporalFile.delete(); - } - mFile.setStoragePath(""); - - } else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_DELETE) { - originalFile.delete(); - } else { - mFile.setStoragePath(expectedPath); - - if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY - try { - move(temporalFile, expectedFile); - } catch (IOException e) { - e.printStackTrace(); - } - } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE - try { - move(originalFile, expectedFile); - } catch (IOException e) { - e.printStackTrace(); - } - getStorageManager().deleteFileInMediaScan(originalFile.getAbsolutePath()); - } - FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath()); - } } else if (result.getCode() == ResultCode.SYNC_CONFLICT) { getStorageManager().saveConflict(mFile, mFile.getEtagInConflict()); }