Revert "Revert "Try to fix changes between upload behaviour""

This reverts commit e7da3ede5e.

# Conflicts:
#	src/com/owncloud/android/operations/UploadFileOperation.java
This commit is contained in:
Mario Danic 2017-03-01 11:47:20 +01:00 committed by AndyScherzinger
parent b3e668ffa6
commit bb20395e98
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -76,6 +76,8 @@ 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
@ -346,7 +348,7 @@ public class UploadFileOperation extends SyncOperation {
throw new OperationCancelledException();
}
String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
expectedFile = new File(expectedPath);
/// copy the file locally before uploading
@ -391,15 +393,8 @@ 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("");
<<<<<<< HEAD
} else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_DELETE) {
originalFile.delete();
getStorageManager().deleteFileInMediaScan(originalFile.getAbsolutePath());
@ -414,6 +409,8 @@ public class UploadFileOperation extends SyncOperation {
}
FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath());
}
=======
>>>>>>> parent of e7da3ed... Revert "Try to fix changes between upload behaviour"
} else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) {
result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
@ -453,6 +450,36 @@ 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());
}