sync: prevent multiple syncs from a single connection

This commit is contained in:
Abdullah Atta
2023-05-22 18:22:32 +05:00
parent 19056a9302
commit 4b67b7eedb

View File

@@ -111,7 +111,9 @@ namespace Notesnook.API.Hubs
var userId = Context.User.FindFirstValue("sub");
if (string.IsNullOrEmpty(userId)) return 0;
var others = Clients.OthersInGroup(userId);
// Only allow a single sync to run per connection. This prevents a bunch of issues like sync loops
// and wasted bandwidth
if (GlobalSync.IsSyncRunning(userId, Context.ConnectionId)) return 0;
if (!GlobalSync.RunningSyncs.ContainsKey(userId))
GlobalSync.RunningSyncs[userId] = new List<RunningSync>();