mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Minor improvements for upload cancelation and conflicts in synchronization
This commit is contained in:
parent
5985ba9a9f
commit
8bf276377c
@ -390,10 +390,15 @@ public class RemoteOperationResult implements Serializable {
|
|||||||
|
|
||||||
} else if (mCode == ResultCode.ACCOUNT_NOT_THE_SAME) {
|
} else if (mCode == ResultCode.ACCOUNT_NOT_THE_SAME) {
|
||||||
return "Authenticated with a different account than the one updating";
|
return "Authenticated with a different account than the one updating";
|
||||||
|
|
||||||
} else if (mCode == ResultCode.INVALID_CHARACTER_IN_NAME) {
|
} else if (mCode == ResultCode.INVALID_CHARACTER_IN_NAME) {
|
||||||
return "The file name contains an forbidden character";
|
return "The file name contains an forbidden character";
|
||||||
|
|
||||||
} else if (mCode == ResultCode.FILE_NOT_FOUND) {
|
} else if (mCode == ResultCode.FILE_NOT_FOUND) {
|
||||||
return "Local file does not exist";
|
return "Local file does not exist";
|
||||||
|
|
||||||
|
} else if (mCode == ResultCode.SYNC_CONFLICT) {
|
||||||
|
return "Synchronization conflict";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Operation finished with HTTP status code " + mHttpCode + " (" +
|
return "Operation finished with HTTP status code " + mHttpCode + " (" +
|
||||||
|
@ -32,8 +32,7 @@ public class Log_OC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void i(String TAG, String message){
|
public static void i(String TAG, String message){
|
||||||
|
Log.i(TAG, message);
|
||||||
// Write the log message to the file
|
|
||||||
appendLog(TAG+" : "+ message);
|
appendLog(TAG+" : "+ message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int uploadFile(OwnCloudClient client) throws HttpException, IOException {
|
protected int uploadFile(OwnCloudClient client) throws IOException {
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
FileChannel channel = null;
|
FileChannel channel = null;
|
||||||
|
@ -140,6 +140,9 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
if (transferred == totalToTransfer) { // Check if the file is completed
|
if (transferred == totalToTransfer) { // Check if the file is completed
|
||||||
savedFile = true;
|
savedFile = true;
|
||||||
Header modificationTime = mGet.getResponseHeader("Last-Modified");
|
Header modificationTime = mGet.getResponseHeader("Last-Modified");
|
||||||
|
if (modificationTime == null) {
|
||||||
|
modificationTime = mGet.getResponseHeader("last-modified");
|
||||||
|
}
|
||||||
if (modificationTime != null) {
|
if (modificationTime != null) {
|
||||||
Date d = WebdavUtils.parseResponseDate((String) modificationTime.getValue());
|
Date d = WebdavUtils.parseResponseDate((String) modificationTime.getValue());
|
||||||
mModificationTimestamp = (d != null) ? d.getTime() : 0;
|
mModificationTimestamp = (d != null) ? d.getTime() : 0;
|
||||||
|
@ -102,8 +102,7 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
|||||||
(mPutMethod != null ? mPutMethod.getResponseHeaders() : null));
|
(mPutMethod != null ? mPutMethod.getResponseHeaders() : null));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO something cleaner with cancellations
|
if (mCancellationRequested.get() && !(e instanceof OperationCancelledException)) {
|
||||||
if (mCancellationRequested.get()) {
|
|
||||||
result = new RemoteOperationResult(new OperationCancelledException());
|
result = new RemoteOperationResult(new OperationCancelledException());
|
||||||
} else {
|
} else {
|
||||||
result = new RemoteOperationResult(e);
|
result = new RemoteOperationResult(e);
|
||||||
@ -117,8 +116,7 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
|||||||
status == HttpStatus.SC_NO_CONTENT));
|
status == HttpStatus.SC_NO_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int uploadFile(OwnCloudClient client) throws HttpException, IOException,
|
protected int uploadFile(OwnCloudClient client) throws IOException {
|
||||||
OperationCancelledException {
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
try {
|
try {
|
||||||
File f = new File(mLocalPath);
|
File f = new File(mLocalPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user