From cf16aa0c4e27a8dd232ec5b1da3d8558861d5f84 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 17 Aug 2023 20:32:38 +0200 Subject: [PATCH] Cloud sync: check for duplicate uuids --- .../main/java/eu/faircode/email/CloudSync.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/CloudSync.java b/app/src/main/java/eu/faircode/email/CloudSync.java index 9c2fd993f2..20ce5a307f 100644 --- a/app/src/main/java/eu/faircode/email/CloudSync.java +++ b/app/src/main/java/eu/faircode/email/CloudSync.java @@ -258,12 +258,21 @@ public class CloudSync { if (accounts == null || accounts.size() == 0) return; + List uuidAccounts = new ArrayList<>(); + List uuidIdentities = new ArrayList<>(); + JSONArray jupload = new JSONArray(); JSONArray jaccountuuidlist = new JSONArray(); for (EntityAccount account : accounts) if (account.synchronize && !TextUtils.isEmpty(account.uuid) && account.auth_type != ServiceAuthenticator.AUTH_TYPE_GMAIL) { + if (uuidAccounts.contains(account.uuid)) { + Log.w("Duplicate account uuid=" + account.uuid); + continue; + } else + uuidAccounts.add(account.uuid); + jaccountuuidlist.put(account.uuid); JSONArray jidentitieuuids = new JSONArray(); @@ -271,6 +280,12 @@ public class CloudSync { if (identities != null) for (EntityIdentity identity : identities) if (identity.synchronize && !TextUtils.isEmpty(identity.uuid)) { + if (uuidIdentities.contains(identity.uuid)) { + Log.w("Duplicate identity uuid=" + identity.uuid); + continue; + } else + uuidIdentities.add(identity.uuid); + jidentitieuuids.put(identity.uuid); JSONObject jidentity = identity.toJSON();