Journal: don't attempt fetching entries if we are already up to date.

For a while now, etesync servers return the last entry uid as part of the
general journal querying. We can use this to check if we even need to
update the journals or not, making the overall sync much faster because
we no longer need to fetch journals that haven't changed.
pull/122/head
Tom Hacohen 4 years ago
parent c75d3a3b08
commit 47c96963e9

@ -55,7 +55,7 @@ class App : Application() {
get() = initDataStore()
fun initDataStore(): MyEntityDataStore {
val source = MyDatabaseSource(this, Models.DEFAULT, 5)
val source = MyDatabaseSource(this, Models.DEFAULT, 6)
val configuration = source.configuration
return MyEntityDataStore(configuration)
}

@ -37,6 +37,8 @@ public class JournalModel {
byte[] encryptedKey;
@Column(length = 64)
String remoteLastUid;
@Deprecated
long service;

@ -247,6 +247,7 @@ abstract class SyncAdapterService : Service() {
journalEntity.encryptedKey = journal.key
journalEntity.isReadOnly = journal.readOnly
journalEntity.isDeleted = false
journalEntity.remoteLastUid = journal.lastUid
data.upsert(journalEntity)
existing.remove(collection.uid)

@ -364,6 +364,12 @@ constructor(protected val context: Context, protected val account: Account, prot
}
}
} else {
if ((remoteCTag != null) && (journalEntity.remoteLastUid == remoteCTag)) {
Logger.log.info("Skipping fetch because local lastUid == remoteLastUid (${remoteCTag})")
remoteEntries = LinkedList()
return
}
remoteEntries = journal!!.list(crypto, remoteCTag, MAX_FETCH)
}

Loading…
Cancel
Save