mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
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:
parent
b3e668ffa6
commit
bb20395e98
1 changed files with 36 additions and 9 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue