Commit Graph

673 Commits

Author SHA1 Message Date
Damien Elmes
c96784c0eb fix new clippy lints 2020-10-09 21:35:53 +10:00
Damien Elmes
90fa38495e reindex when checking database
Came across a user with a corrupt index:

sqlite> pragma integrity_check;
 integrity_check = wrong # of entries in index ix_revlog_cid
 integrity_check = wrong # of entries in index ix_cards_sched

This is not picked up by a quick check, and a vacuum does not
fix it, but a reindex does.

AnkiWeb currently performs a full check when a file is uploaded
to it, so this was leading to "corrupt" to show up when syncing
the collection, with a local DB check not reporting/fixing the issue.
2020-10-05 17:40:43 +10:00
Damien Elmes
53a984ba15 bump version 2020-10-02 10:22:21 +10:00
Damien Elmes
955c1bafb9 fix * handling in unqualifed text as well
https://forums.ankiweb.net/t/anki-2-1-desktop-searching-with-only-when-limited-to-a-field/3789/4
2020-09-29 21:18:19 +10:00
Damien Elmes
7e872de875 fix escaping of * in field search
mentioned in
https://github.com/ankitects/anki/pull/769
2020-09-27 16:04:08 +10:00
Damien Elmes
c125893eba bump version 2020-09-24 10:52:24 +10:00
Damien Elmes
cc3fdb2f37 rename downgrade method for clarity 2020-09-22 15:53:26 +10:00
Damien Elmes
76acf04dc0 update schema to fix default initial ease in deck configs
Closes #766

- changes the on-disk representation from % to a multiplier,
eg 250 -> 2.5, as this is consistent with the other options
- resets deck configs at or below 1.3 to 2.5
- for any cards that were using a reset deck config, reset their
current factor if it's at or below 2.0x. The cutoff is arbitrary,
and just intended to make sure we catch cards the user has rated
Easy on multiple times. The existing due dates are left alone.
2020-09-22 08:16:39 +10:00
Damien Elmes
d74cc2e9b0 stop is:due gathering learning cards that are not due yet
https://forums.ankiweb.net/t/how-to-avoid-rebuilding-filtered-decks-to-skip-learning-cards-steps/3551/
2020-09-21 11:41:54 +10:00
Damien Elmes
755a58b96c fix incorrect SQL in previous change 2020-09-19 12:27:00 +10:00
Damien Elmes
91759694a1 congrats_info() failed if learning card had negative due
https://forums.ankiweb.net/t/integralvalueoutofrange-for-filtered-deck/3353
2020-09-18 20:14:35 +10:00
Damien Elmes
8bde6749b1 sched_timing_today() needs a default rollover hour
When unset it was reverting to the V1 code.

https://forums.ankiweb.net/t/daily-counts-are-reset-on-sync/3441/16
2020-09-18 19:13:47 +10:00
Damien Elmes
caa703126c check original due in card stats
https://forums.ankiweb.net/t/how-come-some-of-my-cards-are-showing-retrospective-due-dates/3434/6
2020-09-17 14:36:18 +10:00
Aleksa Sarai
16864e616f
rust: switch to stable compilers
The only dependency which required nightly compilers was pyo3, which
supports stable Rust (1.39.0 and later) since version 0.11.0. Supporting
stable Rust makes it easier to package Anki for distributions. No other
code changes were required.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:39:51 +10:00
Aleksa Sarai
d2ada5a1ee
rslib: disable bzip2 feature
We can't link against libzip2.so.1 when building manylinux wheels, but
the only dependency which required this was "zip" and we don't appear to
make use of bzip2 in Anki.

This fixes the following "make build" error on Linux:

  x maturin failed
    Caused by: Failed to ensure manylinux compliance
    Caused by: Your library is not manylinux compliant because it links the following forbidden libraries: ["libbz2.so.1"]

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:39:11 +10:00
Aleksa Sarai
312393e825
rs: remove most &mut references in BackendService
The previous implementation had some slightly questionable memory safety
properties (older versions of PyO3 didn't uphold the Rust aliasing rules
and would thus create multiple &mut references to #[pyclass] objects).
This explains why Backend has internal Mutex<T>s even though all of its
methods took &mut self.

The solution is to simply make all methods take &self, which luckily
doesn't pose too make issues -- most of the code inside Backend already
has sufficient locking. The only two things which needed to be
explicitly handled where:

1. "self.runtime" which was fairly easy to handle. All usages of
   the Runtime only require an immutable reference to create a new
   Handle, so we could switch to OnceCell which provides
   lazy-initialisation semantics without needing a more heavy-handed
   Mutex<tokio::runtime::Handle>.

2. "self.sync_abort" was simply wrapped in a Mutex<>, though some of the
   odd semantics of sync_abort (not being able to handle multiple
   processes synchronising at the same time) become pretty obvious with
   this change (for now we just log a warning in that case). In
   addition, switch to an RAII-style guard to make sure we don't forget
   to clear the abort_handle.

As a result, we now no longer break Rust's aliasing rules and we can
build with newer versions of PyO3 which have runtime checks for these
things (and build on stable Rust).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:37:59 +10:00
Aleksa Sarai
70339e07f9
rslib: auto-format protobuf code
prost-build doesn't generate rustfmt-safe code, so we had to add it to
the ignore list for rustfmt on "make check". However, the ignore list
isn't supported by stable rustfmt, so we have to work around this some
other way -- in this case, just do "rustfmt" on the generated file in
"build.rs" (this way, formatting errors in checked-in source code are
still caught but generated code doesn't cause spurrious errors).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-04 16:30:06 +10:00
Damien Elmes
c82a084edf handle quoted html chars in media check
https://forums.ankiweb.net/t/unable-to-play-longer-audio-on-cards/1313/30
2020-09-04 09:36:38 +10:00
Damien Elmes
56ceb6ba76 set_deck() 2020-09-03 17:42:46 +10:00
Damien Elmes
9214c4a700 support did:[deck id] search 2020-09-03 16:43:22 +10:00
Damien Elmes
97778bec43 log 0 day interval as 1 day
Allows distinguishing it from resetting to new, and is treated as
a one day delay when answering anyway.
2020-09-03 16:00:06 +10:00
Damien Elmes
b65174a026 move card sorting and resetting to backend 2020-09-03 15:54:15 +10:00
Damien Elmes
e56f83be84 set local offset when saving preferences 2020-09-03 12:43:18 +10:00
Damien Elmes
ce49ca9401 log manual reschedule, but ignore the log entry in the stats 2020-09-02 17:56:23 +10:00
Damien Elmes
39212a38aa move reschedCards() to backend 2020-09-02 17:56:23 +10:00
Damien Elmes
8f9037cf0f move filtered deck empty/fill to backend
emptying of individual card ids still to be done
2020-09-02 17:56:23 +10:00
Damien Elmes
a834df60ce rename some card+note fields in backend 2020-09-01 10:24:38 +10:00
Damien Elmes
d3dede057a move bury/suspend into backend 2020-09-01 10:24:38 +10:00
Damien Elmes
ccfa989c62 move unbury/unsuspend routines into backend 2020-09-01 10:24:38 +10:00
Damien Elmes
ac6397ae9e add separate sched/user bury searches, and fix bury enums 2020-09-01 10:24:38 +10:00
Damien Elmes
b0a3861734 handle null return from sum() in other columns 2020-09-01 10:24:38 +10:00
Damien Elmes
e5685254c6 reimplement congrats screen in Rust+Typescript 2020-09-01 10:24:38 +10:00
Damien Elmes
819dce3ab6 bump version 2020-08-31 11:07:54 +10:00
Damien Elmes
9fcd6c66f4 fix nonbreaking spaces breaking media
https://forums.ankiweb.net/t/unable-to-play-longer-audio-on-cards/1313
2020-08-30 11:23:12 +10:00
Soren Bjornstad
a3a1f49be1 fix unanchored regex in bulk tag add routine
Previously, it was not possible to add a substring of an existing tag.
For example, with the tag "foobar", you could not add the tag "foo",
"bar" or "oob".

Because the match was unanchored, the regex checking whether the tag
already existed determined that the tag was present when it was not.
2020-08-28 16:21:23 -05:00
Damien Elmes
4662a9fe1a check if we need to unbury at the start of the sync process
https://forums.ankiweb.net/t/bug-buried-cards-in-filtered-decks-not-being-unburied-next-day/2541/24
2020-08-28 21:09:07 +10:00
Damien Elmes
a7e254e81d catch leading/trailing boolean operators
https://forums.ankiweb.net/t/is-it-only-me-anki-giving-corrupt-collection-error/2424/20
2020-08-27 09:59:29 +10:00
Damien Elmes
7bcec00ef4 fix some clippy lints 2020-08-26 19:02:56 +10:00
Damien Elmes
fe8e3c7c7e use commit hash in reqwests dependency 2020-08-26 18:50:25 +10:00
Damien Elmes
07151faae8 add escape hatch for very slow connections 2020-08-26 18:44:20 +10:00
Damien Elmes
06e00be985 specify I/O timeout
We need to be a bit conservative here due to buffer bloat - in the
upload case on a slow link, it can appear that no I/O is happening
when a buffer is draining.
2020-08-26 18:30:51 +10:00
Damien Elmes
7f15d06c58 vendor reqwest for now, to support read/write timeouts
https://github.com/seanmonstar/reqwest/issues/870

adding back now that fix has been applied to a fork of tokio-io-timeout
2020-08-26 13:24:51 +10:00
Damien Elmes
7e6a65ed3d bump version 2020-08-26 08:05:45 +10:00
Damien Elmes
ef7f61ab39 Revert "vendor reqwest for now, to support read/write timeouts"
This reverts commit cf247baf77.

The separate read and write timeouts were causing syncs to fail - a
long full upload would time out due to no read activity for example.
Reverting until a better fix can be put in place.
2020-08-25 13:28:54 +10:00
Damien Elmes
7d7c791504 bump version 2020-08-24 11:28:22 +10:00
Damien Elmes
134765036c don't crash when upgrading collection with ntid of 0 2020-08-23 14:14:44 +10:00
Damien Elmes
63b8b32602 normalize field before checking duplicates
https://forums.ankiweb.net/t/unicode-normalisation/2531
2020-08-23 12:09:55 +10:00
Damien Elmes
4df89c7c26 ensure we don't crash on a zero field notetype 2020-08-23 12:09:36 +10:00
Damien Elmes
fa46ef9e37 fix empty cards not ignoring <br>
https://forums.ankiweb.net/t/bug-report-empty-cards-are-not-recognized/2555
2020-08-23 11:44:49 +10:00
Damien Elmes
85d99f7348 catch timeout error 2020-08-21 19:03:23 +10:00