syncGroup method

Future<void> syncGroup(
  1. TableSyncGroup group
)

Implementation

Future<void> syncGroup(TableSyncGroup group) async {
  LOG.printInfo([
    'TABLE_SYNC_SERVICE',
    'group started',
    'service=$serviceID',
    'tables=${group.tables.join(',')}',
  ]);
  final connected = await InternetService.hasInternet();
  if (!connected) {
    LOG.printWarn(['TABLE_SYNC_SERVICE', 'group skipped', 'no internet']);
    throw StateError('No hay conexión a internet.');
  }

  await ensureSyncInfoTable();
  await syncTableSchemas(group.tables);

  final syncInfo = await _readSyncInfo();
  for (final tableName in group.tables) {
    _validateSqlIdentifier(tableName, 'table');
    LOG.printInfo(['TABLE_SYNC_SERVICE', tableName, 'table requested']);
    final info = syncInfo[tableName];
    if (info == null) {
      LOG.printError(['TABLE_SYNC_SERVICE', tableName, 'missing sync_info']);
      throw StateError(
        'No sync info found for table `$tableName`. The table was not initialized.',
      );
    }
    await _syncTable(tableName, info);
  }
}