Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2021-04-27 20:22:36 +0300
committerStefan Niedermann <info@niedermann.it>2021-04-27 20:22:36 +0300
commit576aa835084bb7d29cbb9e1a9bca6654ee6e4fbc (patch)
tree5f849c3bc449ead765402ca0375c254baacc8449
parent0348f0a642df5d1a35008f7adcd95de1f4449daf (diff)
Fix parallel synchronization issues which can lead to duplicate primary keys
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java6
-rw-r--r--fastlane/metadata/android/en-US/changelogs/3004001.txt3
2 files changed, 5 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
index 3f8e767b..62101055 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesRepository.java
@@ -163,7 +163,7 @@ public class NotesRepository {
@AnyThread
public void addAccount(@NonNull String url, @NonNull String username, @NonNull String accountName, @NonNull Capabilities capabilities, @NonNull IResponseCallback<Account> callback) {
final Account createdAccount = db.getAccountDao().getAccountById(db.getAccountDao().insert(new Account(url, username, accountName, capabilities)));
- if(createdAccount == null) {
+ if (createdAccount == null) {
callback.onError(new Exception("Could not read created account."));
} else {
callback.onSuccess(createdAccount);
@@ -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
diff --git a/fastlane/metadata/android/en-US/changelogs/3004001.txt b/fastlane/metadata/android/en-US/changelogs/3004001.txt
index b1d2dee0..1a2e41bf 100644
--- a/fastlane/metadata/android/en-US/changelogs/3004001.txt
+++ b/fastlane/metadata/android/en-US/changelogs/3004001.txt
@@ -1,4 +1,5 @@
- ⚠️️ Display confirm dialog when deleting an account with unsynchronized changes (#989) - by @AlpAcA0072
- ➖ Allow dashes in note titles (#1104)
- 🌐 Support links in tables (#1115)
-- 🔌 Handle offline state when adding accounts (#1014) \ No newline at end of file
+- 🔌 Handle offline state when adding accounts (#1014)
+- 🐞 Fix parallel synchronization issues which can lead to duplicate primary keys \ No newline at end of file