1
0
mirror of https://github.com/etesync/android synced 2024-11-15 12:28:57 +00:00

Push entries in chunks instead of all at once.

This commit is contained in:
Tom Hacohen 2017-02-16 16:49:46 +00:00
parent 74b0956f3b
commit 8040ee7d9f

View File

@ -14,7 +14,8 @@ import android.content.Intent;
import android.content.SyncResult;
import android.os.Bundle;
import java.io.FileNotFoundException;
import org.apache.commons.collections4.ListUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
@ -260,9 +261,13 @@ abstract public class SyncManager {
protected void pushEntries() throws Exceptions.HttpException, IOException, ContactsStorageException, CalendarStorageException {
// upload dirty contacts
final int MAX_PUSH = 30;
// FIXME: Deal with failure (someone else uploaded before we go here)
if (!localEntries.isEmpty()) {
journal.putEntries(localEntries, remoteCTag);
for (List<JournalEntryManager.Entry> entries : ListUtils.partition(localEntries, MAX_PUSH)) {
journal.putEntries(entries, remoteCTag);
remoteCTag = entries.get(entries.size() - 1).getUuid();
}
for (LocalResource local : localCollection.getDirty()) {
App.log.info("Added/changed resource with UUID: " + local.getUuid());
@ -272,8 +277,6 @@ abstract public class SyncManager {
for (LocalResource local : localCollection.getDeleted()) {
local.delete();
}
remoteCTag = localEntries.get(localEntries.size() - 1).getUuid();
}
}