mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
Implement applyLocalEntries and create the local entries after fetching.
Since we now use a cached version of the localDeleted/Dirty, we can create the entries after we fetch. We also use the entries to override whatever changes came from the server because we assume (for now) our copy is the correct one.
This commit is contained in:
parent
2bbddd26cd
commit
6ea0b47d79
@ -66,11 +66,6 @@ public class CalendarSyncManager extends SyncManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyLocalEntries() throws IOException, Exceptions.HttpException, ContactsStorageException, CalendarStorageException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareDirty() throws CalendarStorageException, ContactsStorageException {
|
protected void prepareDirty() throws CalendarStorageException, ContactsStorageException {
|
||||||
super.prepareDirty();
|
super.prepareDirty();
|
||||||
|
@ -104,11 +104,6 @@ public class ContactsSyncManager extends SyncManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyLocalEntries() throws IOException, ContactsStorageException, CalendarStorageException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareDirty() throws CalendarStorageException, ContactsStorageException {
|
protected void prepareDirty() throws CalendarStorageException, ContactsStorageException {
|
||||||
super.prepareDirty();
|
super.prepareDirty();
|
||||||
|
@ -143,13 +143,6 @@ abstract public class SyncManager {
|
|||||||
App.log.info("Sync phase: " + syncPhase);
|
App.log.info("Sync phase: " + syncPhase);
|
||||||
prepareLocal();
|
prepareLocal();
|
||||||
|
|
||||||
/* Create journal entries out of local changes. */
|
|
||||||
if (Thread.interrupted())
|
|
||||||
return;
|
|
||||||
syncPhase = SYNC_PHASE_CREATE_LOCAL_ENTRIES;
|
|
||||||
App.log.info("Sync phase: " + syncPhase);
|
|
||||||
createLocalEntries();
|
|
||||||
|
|
||||||
if (Thread.interrupted())
|
if (Thread.interrupted())
|
||||||
return;
|
return;
|
||||||
syncPhase = SYNC_PHASE_FETCH_ENTRIES;
|
syncPhase = SYNC_PHASE_FETCH_ENTRIES;
|
||||||
@ -162,6 +155,13 @@ abstract public class SyncManager {
|
|||||||
App.log.info("Sync phase: " + syncPhase);
|
App.log.info("Sync phase: " + syncPhase);
|
||||||
applyRemoteEntries();
|
applyRemoteEntries();
|
||||||
|
|
||||||
|
/* Create journal entries out of local changes. */
|
||||||
|
if (Thread.interrupted())
|
||||||
|
return;
|
||||||
|
syncPhase = SYNC_PHASE_CREATE_LOCAL_ENTRIES;
|
||||||
|
App.log.info("Sync phase: " + syncPhase);
|
||||||
|
createLocalEntries();
|
||||||
|
|
||||||
if (Thread.interrupted())
|
if (Thread.interrupted())
|
||||||
return;
|
return;
|
||||||
syncPhase = SYNC_PHASE_APPLY_LOCAL_ENTRIES;
|
syncPhase = SYNC_PHASE_APPLY_LOCAL_ENTRIES;
|
||||||
@ -234,7 +234,24 @@ abstract public class SyncManager {
|
|||||||
|
|
||||||
abstract protected void processSyncEntry(SyncEntry cEntry) throws IOException, ContactsStorageException, CalendarStorageException, InvalidCalendarException;
|
abstract protected void processSyncEntry(SyncEntry cEntry) throws IOException, ContactsStorageException, CalendarStorageException, InvalidCalendarException;
|
||||||
|
|
||||||
abstract protected void applyLocalEntries() throws IOException, ContactsStorageException, CalendarStorageException, Exceptions.HttpException;
|
private void applyEntries(List<JournalEntryManager.Entry> entries) throws CalendarStorageException, InvalidCalendarException, ContactsStorageException, IOException {
|
||||||
|
for (JournalEntryManager.Entry entry : entries) {
|
||||||
|
if (Thread.interrupted())
|
||||||
|
return;
|
||||||
|
|
||||||
|
App.log.info("Processing " + entry.toString());
|
||||||
|
|
||||||
|
SyncEntry cEntry = SyncEntry.fromJournalEntry(settings.password(), entry);
|
||||||
|
App.log.info("Processing resource for journal entry " + entry.getUuid());
|
||||||
|
processSyncEntry(cEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyLocalEntries() throws IOException, ContactsStorageException, CalendarStorageException, Exceptions.HttpException, InvalidCalendarException {
|
||||||
|
// FIXME: Need a better strategy
|
||||||
|
// We re-apply local entries so our changes override whatever was written in the remote.
|
||||||
|
applyEntries(localEntries);
|
||||||
|
}
|
||||||
|
|
||||||
protected void queryCapabilities() throws IOException, CalendarStorageException, ContactsStorageException {
|
protected void queryCapabilities() throws IOException, CalendarStorageException, ContactsStorageException {
|
||||||
}
|
}
|
||||||
@ -249,16 +266,7 @@ abstract public class SyncManager {
|
|||||||
|
|
||||||
protected void applyRemoteEntries() throws IOException, ContactsStorageException, CalendarStorageException, InvalidCalendarException {
|
protected void applyRemoteEntries() throws IOException, ContactsStorageException, CalendarStorageException, InvalidCalendarException {
|
||||||
// Process new vcards from server
|
// Process new vcards from server
|
||||||
for (JournalEntryManager.Entry entry : remoteEntries) {
|
applyEntries(remoteEntries);
|
||||||
if (Thread.interrupted())
|
|
||||||
return;
|
|
||||||
|
|
||||||
App.log.info("Processing " + entry.toString());
|
|
||||||
|
|
||||||
SyncEntry cEntry = SyncEntry.fromJournalEntry(settings.password(), entry);
|
|
||||||
App.log.info("Processing resource for journal entry " + entry.getUuid());
|
|
||||||
processSyncEntry(cEntry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void pushEntries() throws Exceptions.HttpException, IOException, ContactsStorageException, CalendarStorageException {
|
protected void pushEntries() throws Exceptions.HttpException, IOException, ContactsStorageException, CalendarStorageException {
|
||||||
|
Loading…
Reference in New Issue
Block a user