Commit graph

676 commits

Author SHA1 Message Date
cecini
e12c09bd11 align rslib get_subnode impl with anki pythonapi find_deck_in_tree, fix nestdeck due counts issue 2020-10-29 23:53:26 +08:00
abdo
29d17bf608 Ensure non-empty names
https://github.com/ankitects/anki/pull/801/
2020-10-22 16:11:06 +03:00
abdo
69da22a2b9 Strip double quotes from names
Strip double quotes from all kinds of names

https://github.com/ankitects/anki/pull/798
2020-10-21 21:48:49 +03:00
Damien Elmes
791894d2d0 fix new clippy lints 2020-10-09 21:35:53 +10:00
Damien Elmes
d3de0bbaff 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
2ed1507162 bump version 2020-10-02 10:22:21 +10:00
Damien Elmes
61bbe6a604 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
2e7c71b415 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
1a619073d7 bump version 2020-09-24 10:52:24 +10:00
Damien Elmes
b39612eb33 rename downgrade method for clarity 2020-09-22 15:53:26 +10:00
Damien Elmes
ea7b8c5e49 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
4d66bafc51 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
2a5ebad11f fix incorrect SQL in previous change 2020-09-19 12:27:00 +10:00
Damien Elmes
35470fdcf3 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
717ea6db3d 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
779a8930e7 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
21769bfa68 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
da040372da 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
96da137314 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
1f95cb3139 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
cce0ee2b03 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
f32d773e25 set_deck() 2020-09-03 17:42:46 +10:00
Damien Elmes
f7d4bf8489 support did:[deck id] search 2020-09-03 16:43:22 +10:00
Damien Elmes
32759a55e4 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
7c169daa95 move card sorting and resetting to backend 2020-09-03 15:54:15 +10:00
Damien Elmes
72142d51c4 set local offset when saving preferences 2020-09-03 12:43:18 +10:00
Damien Elmes
366c5c4774 log manual reschedule, but ignore the log entry in the stats 2020-09-02 17:56:23 +10:00
Damien Elmes
31b7d7d645 move reschedCards() to backend 2020-09-02 17:56:23 +10:00
Damien Elmes
396081d329 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
7f42500e53 rename some card+note fields in backend 2020-09-01 10:24:38 +10:00
Damien Elmes
9f51347e1e move bury/suspend into backend 2020-09-01 10:24:38 +10:00
Damien Elmes
988b3c00c1 move unbury/unsuspend routines into backend 2020-09-01 10:24:38 +10:00
Damien Elmes
4894025cfc add separate sched/user bury searches, and fix bury enums 2020-09-01 10:24:38 +10:00
Damien Elmes
2a6206be91 handle null return from sum() in other columns 2020-09-01 10:24:38 +10:00
Damien Elmes
999b659c3a reimplement congrats screen in Rust+Typescript 2020-09-01 10:24:38 +10:00
Damien Elmes
f3c6d565b0 bump version 2020-08-31 11:07:54 +10:00
Damien Elmes
55ae49e251 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
0614642052 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
7cfeb6cbb3 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
b9f6bde2dc 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
41a47fcf01 fix some clippy lints 2020-08-26 19:02:56 +10:00
Damien Elmes
ed1af61fa6 use commit hash in reqwests dependency 2020-08-26 18:50:25 +10:00
Damien Elmes
fb4105013f add escape hatch for very slow connections 2020-08-26 18:44:20 +10:00
Damien Elmes
8c7c2eeda3 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
2e923b0990 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
2f6d816cdc bump version 2020-08-26 08:05:45 +10:00
Damien Elmes
a6f5d48cca Revert "vendor reqwest for now, to support read/write timeouts"
This reverts commit b3edeaac86.

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
58c8609332 bump version 2020-08-24 11:28:22 +10:00
Damien Elmes
3b8c7f22d2 don't crash when upgrading collection with ntid of 0 2020-08-23 14:14:44 +10:00
Damien Elmes
8c558e4e5d normalize field before checking duplicates
https://forums.ankiweb.net/t/unicode-normalisation/2531
2020-08-23 12:09:55 +10:00