downloadServerChanges method

Future<void> downloadServerChanges()

tries to do a partial synchronization from the server, but falls back to full synchronization when needed

Implementation

Future<void> downloadServerChanges() async {
  _logger.finest('Entered DownloadSynchronizer.sync method');
  final lastChangeId = await this.appDatabase.getLastChangeId();

  if (lastChangeId == null) {
    _logger.finest('... no lastChangeId, so will do full resync');
    await _fullResync();
    return;
  }
  _logger.finest('... will sync from $lastChangeId');
  try {
    final changes = await getServerPendingChanges(
        lastChangeId == '' ? null : lastChangeId);
    await _partialSyncServerChanges(changes);
  } on NotFoundException catch (_) {
    _logger.finest('...Received a NotFoundException, so doing a fullResync');
    await _fullResync();
  }
}