private async Task SyncSnapshotsAsync(string id, CancellationToken token) { try { _logger.LogInformation("Starting snapshot sync"); var snapshots = await _snapshotService.GetAllAsync(token); foreach (var snapshot in snapshots.Where(s => s.IsSynced != true).ToList()) { try { _logger.LogInformation($"Syncing snapshot {snapshot.Id}"); await _serverService.SyncSnapshotAsync(id, snapshot, token); await _snapshotService.SetSyncedAsync(snapshot, token); } catch (Exception ex) { _logger.LogError(ex, $"Error syncing snapshot {snapshot.Id}"); } } _logger.LogInformation("Finished snapshot sync"); } catch (Exception ex) { _logger.LogError(ex, "Error syncing snapshots"); throw; } }