Skip to content

Commit

Permalink
Fix ankidroid#5666 - Sync Failure on Large Dynamic Decks
Browse files Browse the repository at this point in the history
We modified `mReportLimit` in ankidroid#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
  • Loading branch information
david-allison committed Mar 24, 2020
1 parent 7f5171e commit d603f2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/libanki/Sched.java
Original file line number Diff line number Diff line change
Expand Up @@ -2538,19 +2538,20 @@ 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();
_resetRevCount();
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<Activity> contextReference) {
mContextReference = contextReference;
Expand Down
15 changes: 15 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/libanki/SchedV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2796,4 +2796,19 @@ public void setContext(WeakReference<Activity> 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 */
}

0 comments on commit d603f2c

Please sign in to comment.