|
@@ -321,52 +321,49 @@ public class UploadFileOperation extends RemoteOperation {
|
|
|
while (listener.hasNext()) {
|
|
|
mUploadOperation.addDatatransferProgressListener(listener.next());
|
|
|
}
|
|
|
- if (!mCancellationRequested.get()) {
|
|
|
- result = mUploadOperation.execute(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) {
|
|
|
- mFile.setStoragePath(null);
|
|
|
-
|
|
|
- } else {
|
|
|
- mFile.setStoragePath(expectedPath);
|
|
|
- File fileToMove = null;
|
|
|
- if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY
|
|
|
- // ; see where temporalFile was
|
|
|
- // set
|
|
|
- fileToMove = temporalFile;
|
|
|
- } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE
|
|
|
- fileToMove = originalFile;
|
|
|
- }
|
|
|
- if (!expectedFile.equals(fileToMove)) {
|
|
|
- File expectedFolder = expectedFile.getParentFile();
|
|
|
- expectedFolder.mkdirs();
|
|
|
- if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) {
|
|
|
- mFile.setStoragePath(null); // forget the local file
|
|
|
- // by now, treat this as a success; the file was
|
|
|
- // uploaded; the user won't like that the local file
|
|
|
- // is not linked, but this should be a very rare
|
|
|
- // fail;
|
|
|
- // the best option could be show a warning message
|
|
|
- // (but not a fail)
|
|
|
- // result = new
|
|
|
- // RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED);
|
|
|
- // return result;
|
|
|
- }
|
|
|
+ if (mCancellationRequested.get()) {
|
|
|
+ throw new OperationCancelledException();
|
|
|
+ }
|
|
|
+
|
|
|
+ result = mUploadOperation.execute(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) {
|
|
|
+ mFile.setStoragePath(null);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ mFile.setStoragePath(expectedPath);
|
|
|
+ File fileToMove = null;
|
|
|
+ if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY
|
|
|
+ // ; see where temporalFile was
|
|
|
+ // set
|
|
|
+ fileToMove = temporalFile;
|
|
|
+ } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE
|
|
|
+ fileToMove = originalFile;
|
|
|
+ }
|
|
|
+ if (!expectedFile.equals(fileToMove)) {
|
|
|
+ File expectedFolder = expectedFile.getParentFile();
|
|
|
+ expectedFolder.mkdirs();
|
|
|
+ if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) {
|
|
|
+ mFile.setStoragePath(null); // forget the local file
|
|
|
+ // by now, treat this as a success; the file was
|
|
|
+ // uploaded; the user won't like that the local file
|
|
|
+ // is not linked, but this should be a very rare
|
|
|
+ // fail;
|
|
|
+ // the best option could be show a warning message
|
|
|
+ // (but not a fail)
|
|
|
+ // result = new
|
|
|
+ // RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED);
|
|
|
+ // return result;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- // TODO something cleaner with cancellations
|
|
|
- if (mCancellationRequested.get()) {
|
|
|
- result = new RemoteOperationResult(new OperationCancelledException());
|
|
|
- } else {
|
|
|
- result = new RemoteOperationResult(e);
|
|
|
- }
|
|
|
+ result = new RemoteOperationResult(e);
|
|
|
|
|
|
} finally {
|
|
|
if (temporalFile != null && !originalFile.equals(temporalFile)) {
|