From d603f2c31f43915884efd35b1e114d4f845f009d Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison-1@users.noreply.github.com> Date: Tue, 24 Mar 2020 17:19:40 +0000 Subject: [PATCH] Fix #5666 - Sync Failure on Large Dynamic Decks We modified `mReportLimit` in #5326 to allow a user to see how many cards they had if there were more than 1000 in a queue. This had an impact on calculating the number of cards in the current deck, which is required for a sync to ensure that the server and client are consistent. This caused an inconsistency (as we calculate the proper value), and this meant that a full sync needed to occur if a dynamic deck with over 1000 cards in a queue was selected. This fixes the issue by using a new scheduler with the correct `mReportLimit` for calculating the number of cards in the selected deck --- .../src/main/java/com/ichi2/libanki/Sched.java | 5 +++-- .../src/main/java/com/ichi2/libanki/SchedV2.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/Sched.java b/AnkiDroid/src/main/java/com/ichi2/libanki/Sched.java index f0292cbcf3a6..228b6e36dd8b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/Sched.java +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/Sched.java @@ -2538,7 +2538,7 @@ public boolean leechActionSuspend(Card card) { } } - //not in libAnki. Added due to #5666 ( + /** not in libAnki. Added due to #5666: inconsistent selected deck card counts on sync */ public int[] recalculateCounts() { _resetLrnCount(); _resetNewCount(); @@ -2546,11 +2546,12 @@ public int[] recalculateCounts() { return new int[] { mNewCount, mLrnCount, mRevCount }; } - //not in libAnki. Added due to #5666 ( public void setReportLimit(int reportLimit) { this.mReportLimit = reportLimit; } + /** End #5666 */ + public void setContext(WeakReference contextReference) { mContextReference = contextReference; diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/SchedV2.java b/AnkiDroid/src/main/java/com/ichi2/libanki/SchedV2.java index 474d894d1565..a1db214baf34 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/SchedV2.java +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/SchedV2.java @@ -2796,4 +2796,19 @@ public void setContext(WeakReference contextReference) { mContextReference = contextReference; } + /** not in libAnki. Added due to #5666: inconsistent selected deck card counts on sync */ + @Override + public int[] recalculateCounts() { + _resetLrnCount(); + _resetNewCount(); + _resetRevCount(); + return new int[] { mNewCount, mLrnCount, mRevCount }; + } + + @Override + public void setReportLimit(int reportLimit) { + this.mReportLimit = reportLimit; + } + + /** End #5666 */ }