Skip to content

Commit

Permalink
Cloud sync: prevent constraint violation
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jul 16, 2024
1 parent 2b0dcff commit 99da99d
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions app/src/main/java/eu/faircode/email/CloudSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,19 +448,27 @@ private static void receiveRemoteData(Context context, String user, String passw
}
} else {
if (left != null) {
left.account = raccount.id;
left.setProperties();
left.setSpecials(raccount);
left.id = db.folder().insertFolder(left);
raccount.swipe_left = left.id;
EntityFolder existing = db.folder().getFolderByName(raccount.id, left.name);
if (existing == null) {
left.account = raccount.id;
left.setProperties();
left.setSpecials(raccount);
left.id = db.folder().insertFolder(left);
raccount.swipe_left = left.id;
} else
raccount.swipe_left = existing.id;
}

if (right != null) {
right.account = raccount.id;
right.setProperties();
right.setSpecials(raccount);
right.id = db.folder().insertFolder(right);
raccount.swipe_right = right.id;
EntityFolder existing = db.folder().getFolderByName(raccount.id, right.name);
if (existing == null) {
right.account = raccount.id;
right.setProperties();
right.setSpecials(raccount);
right.id = db.folder().insertFolder(right);
raccount.swipe_right = right.id;
} else
raccount.swipe_right = existing.id;
}

db.account().setAccountSwipes(raccount.id, raccount.swipe_left, raccount.swipe_right);
Expand Down

0 comments on commit 99da99d

Please sign in to comment.