Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/src/bloc_like/repository/sync_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class SyncRepository<T> {
final SyncLogStore logStore;
final EntityIdResolver<T> idResolver;

int _logCounter = 0;

SyncRepository({
required this.local,
required this.cloud,
Expand Down Expand Up @@ -105,7 +107,7 @@ class SyncRepository<T> {
}

String _logId() {
final micros = DateTime.now().microsecondsSinceEpoch;
return 'sync_log_$micros';
_logCounter += 1;
return 'sync_log_${DateTime.now().microsecondsSinceEpoch}_$_logCounter';
}
Comment on lines 109 to 112

Copilot AI Feb 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a regression test covering the collision scenario this change fixes (multiple log entries created within the same microsecond). For example, create many logs in a tight loop (or stub DateTime) and assert all generated SyncLog.id values are unique and that markSyncing/markSynced updates the intended log rather than the first match.

Copilot uses AI. Check for mistakes.
}