mirror of
https://github.com/etesync/android
synced 2025-01-26 15:40:55 +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) {
|
public void clearDirty(Resource resource) {
|
||||||
pendingOperations.add(ContentProviderOperation
|
pendingOperations.add(ContentProviderOperation
|
||||||
.newUpdate(ContentUris.withAppendedId(entriesURI(), resource.getLocalID()))
|
.newUpdate(ContentUris.withAppendedId(entriesURI(), resource.getLocalID()))
|
||||||
.withValue(entryColumnDirty(), 0).build());
|
.withValue(entryColumnDirty(), 0)
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit() throws LocalStorageException {
|
public void commit() throws LocalStorageException {
|
||||||
|
@ -109,15 +109,20 @@ public class SyncManager {
|
|||||||
try {
|
try {
|
||||||
Resource res = local.findById(id, false);
|
Resource res = local.findById(id, false);
|
||||||
if (res.getName() != null) // is this resource even present remotely?
|
if (res.getName() != null) // is this resource even present remotely?
|
||||||
|
try {
|
||||||
remote.delete(res);
|
remote.delete(res);
|
||||||
local.delete(res);
|
|
||||||
count++;
|
|
||||||
} catch(NotFoundException e) {
|
} catch(NotFoundException e) {
|
||||||
Log.i(TAG, "Locally-deleted resource has already been removed from server");
|
Log.i(TAG, "Locally-deleted resource has already been removed from server");
|
||||||
} catch(PreconditionFailedException e) {
|
} catch(PreconditionFailedException e) {
|
||||||
Log.i(TAG, "Locally-deleted resource has been changed on the server in the meanwhile");
|
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 (RecordNotFoundException e) {
|
} catch (RecordNotFoundException e) {
|
||||||
Log.e(TAG, "Couldn't read locally-deleted record", e);
|
Log.wtf(TAG, "Couldn't read locally-deleted record", e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
local.commit();
|
local.commit();
|
||||||
@ -141,7 +146,7 @@ public class SyncManager {
|
|||||||
} catch (ValidationException e) {
|
} catch (ValidationException e) {
|
||||||
Log.e(TAG, "Couldn't create entity for adding: " + e.toString());
|
Log.e(TAG, "Couldn't create entity for adding: " + e.toString());
|
||||||
} catch (RecordNotFoundException e) {
|
} catch (RecordNotFoundException e) {
|
||||||
Log.e(TAG, "Couldn't read new record", e);
|
Log.wtf(TAG, "Couldn't read new record", e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
local.commit();
|
local.commit();
|
||||||
|
Loading…
Reference in New Issue
Block a user