mirror of
https://github.com/etesync/android
synced 2025-01-09 07:11:00 +00:00
When applying remote entries, save sync tag after application.
This commit is contained in:
parent
7f0f1b92fa
commit
3e5f3f5429
@ -229,18 +229,21 @@ 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;
|
||||||
|
|
||||||
private void applyEntries(List<JournalEntryManager.Entry> entries, boolean noDelete) throws CalendarStorageException, InvalidCalendarException, ContactsStorageException, IOException, InterruptedException {
|
protected void applyLocalEntries() throws IOException, ContactsStorageException, CalendarStorageException, Exceptions.HttpException, InvalidCalendarException, InterruptedException {
|
||||||
String strTotal = String.valueOf(entries.size());
|
// FIXME: Need a better strategy
|
||||||
|
// We re-apply local entries so our changes override whatever was written in the remote.
|
||||||
|
String strTotal = String.valueOf(localEntries.size());
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (JournalEntryManager.Entry entry : entries) {
|
for (JournalEntryManager.Entry entry : localEntries) {
|
||||||
if (Thread.interrupted())
|
if (Thread.interrupted()) {
|
||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
App.log.info("Processing (" + String.valueOf(i) + "/" + strTotal + ") " + entry.toString());
|
App.log.info("Processing (" + String.valueOf(i) + "/" + strTotal + ") " + entry.toString());
|
||||||
|
|
||||||
SyncEntry cEntry = SyncEntry.fromJournalEntry(settings.password(), entry);
|
SyncEntry cEntry = SyncEntry.fromJournalEntry(settings.password(), entry);
|
||||||
if (noDelete && cEntry.isAction(SyncEntry.Actions.DELETE)) {
|
if (cEntry.isAction(SyncEntry.Actions.DELETE)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
App.log.info("Processing resource for journal entry");
|
App.log.info("Processing resource for journal entry");
|
||||||
@ -248,12 +251,6 @@ abstract public class SyncManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyLocalEntries() throws IOException, ContactsStorageException, CalendarStorageException, Exceptions.HttpException, InvalidCalendarException, InterruptedException {
|
|
||||||
// FIXME: Need a better strategy
|
|
||||||
// We re-apply local entries so our changes override whatever was written in the remote.
|
|
||||||
applyEntries(localEntries, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void queryCapabilities() throws IOException, CalendarStorageException, ContactsStorageException {
|
protected void queryCapabilities() throws IOException, CalendarStorageException, ContactsStorageException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,15 +258,30 @@ abstract public class SyncManager {
|
|||||||
remoteEntries = journal.getEntries(settings.password(), remoteCTag);
|
remoteEntries = journal.getEntries(settings.password(), remoteCTag);
|
||||||
|
|
||||||
App.log.info("Fetched " + String.valueOf(remoteEntries.size()) + " entries");
|
App.log.info("Fetched " + String.valueOf(remoteEntries.size()) + " entries");
|
||||||
|
|
||||||
if (!remoteEntries.isEmpty()) {
|
|
||||||
remoteCTag = remoteEntries.get(remoteEntries.size() - 1).getUuid();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyRemoteEntries() throws IOException, ContactsStorageException, CalendarStorageException, InvalidCalendarException, InterruptedException {
|
protected void applyRemoteEntries() throws IOException, ContactsStorageException, CalendarStorageException, InvalidCalendarException, InterruptedException {
|
||||||
// Process new vcards from server
|
// Process new vcards from server
|
||||||
applyEntries(remoteEntries, false);
|
String strTotal = String.valueOf(remoteEntries.size());
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (JournalEntryManager.Entry entry : remoteEntries) {
|
||||||
|
if (Thread.interrupted()) {
|
||||||
|
throw new InterruptedException();
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
App.log.info("Processing (" + String.valueOf(i) + "/" + strTotal + ") " + entry.toString());
|
||||||
|
|
||||||
|
SyncEntry cEntry = SyncEntry.fromJournalEntry(settings.password(), entry);
|
||||||
|
App.log.info("Processing resource for journal entry");
|
||||||
|
processSyncEntry(cEntry);
|
||||||
|
|
||||||
|
remoteCTag = entry.getUuid();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
saveSyncTag();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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