Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 576aa835 authored by Stefan Niedermann's avatar Stefan Niedermann
Browse files

Fix parallel synchronization issues which can lead to duplicate primary keys

parent 0348f0a6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -775,7 +775,7 @@ public class NotesRepository {
     *
     * @param onlyLocalChanges Whether to only push local changes to the server or to also load the whole list of notes from the server.
     */
    public void scheduleSync(Account account, boolean onlyLocalChanges) {
    public synchronized void scheduleSync(Account account, boolean onlyLocalChanges) {
        if (account == null) {
            Log.i(TAG, SingleSignOnAccount.class.getSimpleName() + " is null. Is this a local account?");
        } else {
@@ -784,6 +784,7 @@ public class NotesRepository {
            }
            Log.d(TAG, "Sync requested (" + (onlyLocalChanges ? "onlyLocalChanges" : "full") + "; " + (Boolean.TRUE.equals(syncActive.get(account.getId())) ? "sync active" : "sync NOT active") + ") ...");
            if (isSyncPossible() && (!Boolean.TRUE.equals(syncActive.get(account.getId())) || onlyLocalChanges)) {
                syncActive.put(account.getId(), true);
                try {
                    SingleSignOnAccount ssoAccount = AccountImporter.getSingleSignOnAccount(context, account.getAccountName());
                    Log.d(TAG, "... starting now");
@@ -798,7 +799,6 @@ public class NotesRepository {
                            if (!onlyLocalChanges && Boolean.TRUE.equals(syncScheduled.get(localAccount.getId()))) {
                                syncScheduled.put(localAccount.getId(), false);
                            }
                            syncActive.put(localAccount.getId(), true);
                        }

                        @Override
+2 −1
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@
- ➖ Allow dashes in note titles (#1104)
- 🌐 Support links in tables (#1115)
- 🔌 Handle offline state when adding accounts (#1014)
- 🐞 Fix parallel synchronization issues which can lead to duplicate primary keys
 No newline at end of file