mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
Fix a bug that deletes entities remotely even if they have changed remotely (closes #197)
This commit is contained in:
parent
8a02601cfc
commit
b1ffdbfa95
@ -222,7 +222,8 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
public void clearDirty(Resource resource) {
|
||||
pendingOperations.add(ContentProviderOperation
|
||||
.newUpdate(ContentUris.withAppendedId(entriesURI(), resource.getLocalID()))
|
||||
.withValue(entryColumnDirty(), 0).build());
|
||||
.withValue(entryColumnDirty(), 0)
|
||||
.build());
|
||||
}
|
||||
|
||||
public void commit() throws LocalStorageException {
|
||||
|
@ -109,15 +109,20 @@ public class SyncManager {
|
||||
try {
|
||||
Resource res = local.findById(id, false);
|
||||
if (res.getName() != null) // is this resource even present remotely?
|
||||
remote.delete(res);
|
||||
try {
|
||||
remote.delete(res);
|
||||
} catch(NotFoundException e) {
|
||||
Log.i(TAG, "Locally-deleted resource has already been removed from server");
|
||||
} catch(PreconditionFailedException e) {
|
||||
Log.i(TAG, "Locally-deleted resource has been changed on the server in the meanwhile");
|
||||
}
|
||||
|
||||
// always delete locally so that the record with the DELETED flag doesn't cause another deletion attempt
|
||||
local.delete(res);
|
||||
|
||||
count++;
|
||||
} catch(NotFoundException e) {
|
||||
Log.i(TAG, "Locally-deleted resource has already been removed from server");
|
||||
} catch(PreconditionFailedException e) {
|
||||
Log.i(TAG, "Locally-deleted resource has been changed on the server in the meanwhile");
|
||||
} catch (RecordNotFoundException e) {
|
||||
Log.e(TAG, "Couldn't read locally-deleted record", e);
|
||||
Log.wtf(TAG, "Couldn't read locally-deleted record", e);
|
||||
}
|
||||
} finally {
|
||||
local.commit();
|
||||
@ -141,7 +146,7 @@ public class SyncManager {
|
||||
} catch (ValidationException e) {
|
||||
Log.e(TAG, "Couldn't create entity for adding: " + e.toString());
|
||||
} catch (RecordNotFoundException e) {
|
||||
Log.e(TAG, "Couldn't read new record", e);
|
||||
Log.wtf(TAG, "Couldn't read new record", e);
|
||||
}
|
||||
} finally {
|
||||
local.commit();
|
||||
|
Loading…
Reference in New Issue
Block a user