Upload operations end in conflict if overriding a version different than the last known

This commit is contained in:
David A. Velasco 2015-09-28 11:21:33 +02:00
parent fb482fa33a
commit 001801a39b
3 changed files with 10 additions and 3 deletions

@ -1 +1 @@
Subproject commit 092c790030ef42b34352225e9c1d8480a0e38674 Subproject commit eb4f8a723490a18c5a07fbdc3bf19928c49c4a10

View file

@ -572,6 +572,9 @@ public class FileUploader extends Service
uploadResult = mCurrentUpload.execute(mUploadClient); uploadResult = mCurrentUpload.execute(mUploadClient);
if (uploadResult.isSuccess()) { if (uploadResult.isSuccess()) {
saveUploadedFile(); saveUploadedFile();
} else if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
mStorageManager.saveConflict(mCurrentUpload.getFile(), true);
} }
} else { } else {
uploadResult = grantResult; uploadResult = grantResult;

View file

@ -31,6 +31,7 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.commons.httpclient.methods.RequestEntity;
import android.accounts.Account; import android.accounts.Account;
@ -310,10 +311,10 @@ public class UploadFileOperation extends RemoteOperation {
(new File(mFile.getStoragePath())).length() > (new File(mFile.getStoragePath())).length() >
ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) { ChunkedUploadRemoteFileOperation.CHUNK_SIZE ) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mFile.getStoragePath(), mUploadOperation = new ChunkedUploadRemoteFileOperation(mFile.getStoragePath(),
mFile.getRemotePath(), mFile.getMimetype()); mFile.getRemotePath(), mFile.getMimetype(), mFile.getEtag());
} else { } else {
mUploadOperation = new UploadRemoteFileOperation(mFile.getStoragePath(), mUploadOperation = new UploadRemoteFileOperation(mFile.getStoragePath(),
mFile.getRemotePath(), mFile.getMimetype()); mFile.getRemotePath(), mFile.getMimetype(), mFile.getEtag());
} }
Iterator <OnDatatransferProgressListener> listener = mDataTransferListeners.iterator(); Iterator <OnDatatransferProgressListener> listener = mDataTransferListeners.iterator();
while (listener.hasNext()) { while (listener.hasNext()) {
@ -358,6 +359,9 @@ public class UploadFileOperation extends RemoteOperation {
} }
} }
} }
} else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) {
result = new RemoteOperationResult(ResultCode.CONFLICT);
} }
} catch (Exception e) { } catch (Exception e) {