Skip to content

Commit

Permalink
Revert "Try to fix changes between upload behaviour"
Browse files Browse the repository at this point in the history
This reverts commit c61ad34.
  • Loading branch information
mario authored and AndyScherzinger committed Feb 28, 2017
1 parent 5a41317 commit e7da3ed
Showing 1 changed file with 22 additions and 33 deletions.
55 changes: 22 additions & 33 deletions src/com/owncloud/android/operations/UploadFileOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -348,7 +346,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
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
Expand Down Expand Up @@ -393,7 +391,28 @@ protected RemoteOperationResult run(OwnCloudClient client) {
/// 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);
Expand Down Expand Up @@ -433,36 +452,6 @@ protected RemoteOperationResult run(OwnCloudClient client) {
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());
}
Expand Down

0 comments on commit e7da3ed

Please sign in to comment.