Revert "Try to fix changes between upload behaviour"

This reverts commit c61ad342e462ebba43a4022d4214ed2bfe13cb6f.
This commit is contained in:
Mario Danic 2017-02-22 15:20:32 +01:00 committed by AndyScherzinger
parent 5a41317193
commit e7da3ede5e
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -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_PICTURE = 1;
public static final int CREATED_AS_INSTANT_VIDEO = 2; public static final int CREATED_AS_INSTANT_VIDEO = 2;
private String expectedPath;
public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) { public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) {
// MIME type // MIME type
@ -348,7 +346,7 @@ public class UploadFileOperation extends SyncOperation {
throw new OperationCancelledException(); throw new OperationCancelledException();
} }
expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile); String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
expectedFile = new File(expectedPath); expectedFile = new File(expectedPath);
/// copy the file locally before uploading /// 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 /// move local temporal file or original file to its corresponding
// location in the ownCloud local folder // location in the ownCloud local folder
if (result.isSuccess()) { 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 ) { } else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) {
result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
@ -433,36 +452,6 @@ public class UploadFileOperation extends SyncOperation {
if (result.isSuccess()) { if (result.isSuccess()) {
saveUploadedFile(client); 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) { } else if (result.getCode() == ResultCode.SYNC_CONFLICT) {
getStorageManager().saveConflict(mFile, mFile.getEtagInConflict()); getStorageManager().saveConflict(mFile, mFile.getEtagInConflict());
} }