Commit Graph

142 Commits

Author SHA1 Message Date
Damien Elmes
6ba321f818 sanitize deck description in decks screen on backend
Looks like ammonia only adds about 800k to the release binary
2021-02-06 13:42:38 +10:00
Damien Elmes
da407a5000 pin proc_macro_nested due to Windows breakage 2021-02-03 21:17:11 +10:00
Damien Elmes
9225c804db update Rust deps; add async_trait 2021-01-11 19:19:45 +10:00
Damien Elmes
40c5f8a907 update prost to new 0.7 release+auto stage changes
Allows us to drop slow git repo.
2020-12-28 10:12:35 +10:00
cecini
d37ea0f5f7 Update rslib dep nom 2020-12-15 08:19:52 +00:00
Damien Elmes
c9b3ed1eae switch to workspace for Rust code 2020-11-24 18:41:03 +10:00
Damien Elmes
4bf93a9af0 add native-tls in preparation for Linux-only ring 2020-11-15 14:02:53 +10:00
Damien Elmes
0489c92908 drop El Capitan support 2020-11-12 20:03:41 +10:00
Damien Elmes
3c12cb1600 update to latest fluent libs, and integrate maximum digit handling
We now limit number of digits in our formatter, instead of relying
on an upstream patch.
2020-11-03 14:10:45 +10:00
Damien Elmes
ef79596c5b add shallow_since to a bunch of git deps 2020-11-03 11:42:11 +10:00
Damien Elmes
8f5474bef0 ues native roots with rustls 2020-11-03 10:42:20 +10:00
Damien Elmes
e54bb9d1bf update env_logger, and minor dep updates 2020-11-03 09:04:57 +10:00
Damien Elmes
35f5358bf7 reqwest was missing default-features = false
Still needed until we fix OpenSSL compilation on Linux
2020-11-02 21:53:24 +10:00
Damien Elmes
a079bb1820 update rusqlite and pin-project
Thanks to Alan for the heads up
2020-11-02 18:26:19 +10:00
Damien Elmes
dc3bd07919 update cargo deps; add script to copy them from rslib/ 2020-11-02 18:17:26 +10:00
Damien Elmes
aea0a6fcc6 initial Bazel conversion
Running and testing should be working on the three platforms, but
there's still a fair bit that needs to be done:

- Wheel building + testing in a venv still needs to be implemented.
- Python requirements still need to be compiled with piptool and pinned;
need to compile on all platforms then merge
- Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally
unified into one place
- Currently using rustls to work around openssl compilation issues
on Linux, but this will break corporate proxies with custom SSL
authorities; need to conditionally use openssl or use
https://github.com/seanmonstar/reqwest/pull/1058
- Makefiles and docs still need cleaning up
- It may make sense to reparent ts/* to the top level, as we don't
nest the other modules under a specific language.
- rspy and pylib must always be updated in lock-step, so merging
rspy into pylib as a private module would simplify things.
- Merging desktop-ftl and mobile-ftl into the core ftl would make
managing and updating translations easier.
- Obsolete scripts need removing.
- And probably more.
2020-11-01 14:26:58 +10:00
Damien Elmes
53a984ba15 bump version 2020-10-02 10:22:21 +10:00
Damien Elmes
c125893eba bump version 2020-09-24 10:52:24 +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
Damien Elmes
819dce3ab6 bump version 2020-08-31 11:07:54 +10:00
Damien Elmes
fe8e3c7c7e use commit hash in reqwests dependency 2020-08-26 18:50:25 +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
cf247baf77 vendor reqwest for now, to support read/write timeouts
https://github.com/seanmonstar/reqwest/issues/870
2020-08-21 18:50:00 +10:00
Damien Elmes
b380f304bf bump version 2020-08-09 13:44:59 +10:00
Damien Elmes
227703f9fa bump version 2020-07-28 12:59:56 +10:00
Damien Elmes
412f1777bd bump version 2020-07-21 15:54:14 +10:00
Damien Elmes
1205db6484 panic fix was merged into hyper 0.13.7 2020-07-16 09:09:13 +10:00
Damien Elmes
df5487875b vendor coarsetime so we can get the use after free fix 2020-07-13 13:34:37 +10:00
Damien Elmes
75443b5171 update rslib/rspy deps 2020-07-12 11:38:25 +10:00
Damien Elmes
b51f03085e migrate card stats to backend
Currently this renders the HTML directly like the previous Python
implementation - doing it in JS would probably make more sense in the
future.
2020-06-15 17:22:16 +10:00
Damien Elmes
10a1d06dce use vendored hyper for panic fix 2020-06-11 13:30:35 +10:00
Damien Elmes
9e56720c2b Revert "use trust-dns in reqwest"
This reverts commit abe90d0772.

trust-dns has introduced its own issues, such as when resolv.conf is
inaccessible, or contains hostnames with certain characters
2020-06-08 22:03:24 +10:00
Damien Elmes
abe90d0772 use trust-dns in reqwest
The default DNS resolution, if interrupted by an Abortable, will
cause a panic:

57ef271500/src/client/connect/dns.rs (L144)
2020-06-03 15:47:54 +10:00
Damien Elmes
ac219ae728 use a shared async runtime instead of recreating each time 2020-06-02 09:35:27 +10:00
Damien Elmes
529e89f48e full upload/download HTTP code 2020-06-01 13:57:10 +10:00
Damien Elmes
4fcb10bfa9 start on HTTP client for syncing 2020-06-01 13:57:10 +10:00
Damien Elmes
8bd5d756e2 bump version 2020-05-18 12:50:20 +10:00
Damien Elmes
da43d22aa5 update rusqlite 2020-05-16 19:49:08 +10:00
Damien Elmes
83bcb084fe template changes and card generation
Cloze cards are not yet supported, missing decks are not handled,
and more testing is still required.
2020-05-12 21:13:33 +10:00
Damien Elmes
f24dc05c8d the start of note adding, and note type changes 2020-05-12 21:13:33 +10:00
Damien Elmes
08ae4e7900 update crate version
make check was missing this
2020-05-11 20:41:16 +10:00
Damien Elmes
36ea980725 update rslib version 2020-05-02 10:46:58 +10:00
Damien Elmes
00cf4fc585 bump version 2020-04-28 08:57:56 +10:00
Damien Elmes
11fdd96a44 add socks support 2020-04-09 14:28:36 +10:00
Damien Elmes
92fbe3bfba update rusqlite 2020-04-09 12:45:51 +10:00
Damien Elmes
c950a00610 Cow<str> workaround no longer required 2020-04-07 10:08:03 +10:00
Damien Elmes
caa513899d update rusqlite for param count assert fix 2020-04-07 08:54:57 +10:00
Damien Elmes
ac4284b2de update tag handling
- tag list stored in a separate DB table
- non-wildcard searches now do full unicode case folding
(eg tag:masse matches 'Maße')
- wildcard matches do simple unicode case folding
- some functions haven't been updated yet, so ascii folding will
continue to be used in some operations
2020-04-03 19:34:46 +10:00
Damien Elmes
ee71e5dd59 use support URL and point to source repo 2020-04-03 08:44:59 +10:00
evandrocoan
069cc11a86 Created the GitHub Actions step Upload to PyPi to run only on
tagged releases of anki:
https://anki.tenderapp.com/discussions/ankidesktop/40025-anki-in-python-package-index
2020-04-02 02:57:34 -03:00
Damien Elmes
c9da4bc1a6 allow aborting a media sync while http req in flight
The progress handling code needs a rethink, as we now have two separate
ways to flag that the media sync should abort. In the future, it may
make sense to switch to polling the backend for progress, instead of
passing a callback in.
2020-04-01 09:49:25 +10:00
Damien Elmes
2810d3883b roll back the vec cache changes
prepare_cached() is sufficiently fast, and allowing the vec cache
to persist across calls is complicated due to lifetime restrictions
2020-03-29 09:26:09 +10:00
Damien Elmes
1a1a00d50f Revert "add benchmark for vec cache"
This reverts commit 82ed288dc5.
2020-03-29 09:16:11 +10:00
Damien Elmes
82ed288dc5 add benchmark for vec cache
test storage::sqlite::bench::bench_hash_cache ... bench:         399 ns/iter (+/- 27)
test storage::sqlite::bench::bench_no_cache   ... bench:       4,854 ns/iter (+/- 499)
test storage::sqlite::bench::bench_vec_cache  ... bench:           0 ns/iter (+/- 0)
2020-03-27 09:59:48 +10:00
Damien Elmes
2f4e35d566 store cached statements in a vec instead of separate optionals 2020-03-27 09:51:19 +10:00
Damien Elmes
289bdde20c handle fields with embedded nuls 2020-03-24 14:53:33 +10:00
Damien Elmes
4ff17d31b3 add unicase collation
sqlite's like is hard-coded to use ASCII comparisons, so we can't
take advantage of this yet
2020-03-21 12:40:20 +10:00
Damien Elmes
7eab504126 add field_at_index() sql func 2020-03-20 21:15:23 +10:00
Damien Elmes
761d1d1812 add card queue/type enums 2020-03-20 21:15:23 +10:00
Damien Elmes
f617760d04 bump version 2020-03-19 10:46:01 +10:00
Damien Elmes
071722c057 rspy version 2020-03-06 19:15:02 +10:00
Damien Elmes
f7ec2faba6 update to failure 0.1.7 2020-03-06 15:08:58 +10:00
Damien Elmes
bb0e5dfa93 work around bug in failure crate 2020-03-05 11:06:44 +10:00
Damien Elmes
ba4fe71eba make logging explicit, and support logging to a file 2020-02-29 20:44:01 +10:00
Alan Du
3ebdaa14de Update blake3 to 0.2 2020-02-26 22:50:48 -05:00
Alan Du
3867c20cfd Update prost-build version to 0.6
This is the same version as Prost, and lets us reduce the number of deps
we have to compile
2020-02-26 22:48:16 -05:00
Damien Elmes
b412747a16 add workaround for panic on 32 bit systems
https://anki.tenderapp.com/discussions/beta-testing/1817-failed-to-generate-operands-out-of-fluentnumber-could-not-convert-string-to-integer
2020-02-25 13:22:41 +10:00
Damien Elmes
4430c67069 rework Fluent handling
- all .ftl files for a language are concatenated into a single file
at build time
- all languages are included in the binary
- external ftl files placed in the ftl folder can override the
built-in definitions
- constants are automatically generated for each string key
- dropped the separate StringsGroup enum
2020-02-23 13:22:50 +10:00
Damien Elmes
e31d576740 fluent-rs git no longer required 2020-02-21 21:30:11 +10:00
Damien Elmes
ffffdf2c85 fix revision pin 2020-02-21 15:29:38 +10:00
Damien Elmes
370bb38b8b update to latest fluent-rs and add basic locale-aware decimals
- git version pinned at the moment until the concurrency fix
lands in 0.10.2
- currently float values are hard-coded at 2 decimal places;
we should switch to using NUMBER() in the future
2020-02-21 15:29:38 +10:00
Damien Elmes
683b7983f8 pin coarsetime for now, as .12 requires Sierra 2020-02-17 17:55:39 +10:00
Damien Elmes
61b9f70ab9 bump version 2020-02-17 08:40:17 +10:00
Damien Elmes
dc9362d4ed add i18n support to Rust code using Fluent 2020-02-17 08:40:17 +10:00
Damien Elmes
fabfcb0338 gather field references in Rust; media check now mostly complete 2020-02-17 08:40:17 +10:00
Damien Elmes
e9f51a694c use our own trash folder instead of using the system trash
the trash crate was invoking external commands on Macs and Linux
which is slow and likely to fall over if a large number of files need
to be deleted at once.
2020-02-17 08:40:17 +10:00
Damien Elmes
7ae6244f6a log media DB change registration progress, and allow aborting it 2020-02-17 08:40:17 +10:00
Damien Elmes
fb8f753d2d update rslib version automatically 2020-02-17 08:40:17 +10:00
Damien Elmes
0fb70dab0f comply with manylinux wheel requirements, and vendor sqlite on Windows 2020-02-17 08:40:17 +10:00
Damien Elmes
d0ee95c4cd send removed files to the trash
The way the trash crate implements deletion on a Mac is ugly, and
we may need to look into alternatives.
2020-02-17 08:40:16 +10:00
Damien Elmes
f20b5b8db6 media sync working, but unpolished 2020-02-17 08:40:16 +10:00
Damien Elmes
96f0a5cc3c port change tracking 2020-02-17 08:40:16 +10:00
Damien Elmes
056c2d3fd1 initial rs implementation of media database 2020-02-17 08:40:16 +10:00
Damien Elmes
41266f46f1 add another implementation of media.addFile() and cleanFilename() et al
Instead of adding an incrementing number in the conflict case,
the file hash is appended.
2020-02-17 08:40:16 +10:00
Damien Elmes
0942ffbff6 add a simple TTS field filter
This simply wraps the field in extra text that the frontend will
deal with. Also added some helpers for extracting and stripping
audio and TTS tags from the rendered text.
2020-01-20 19:16:24 +10:00
Damien Elmes
94a72f970a type: and hint: support
We may need to keep handling hints in the Python code for now until
i18n is sorted out.
2020-01-11 09:35:41 +10:00
Damien Elmes
f7ff0d1c17 flatten->render; pass field content in
This is paving the way to move the standard filters into Rust.

Non-empty fields are now determined in Rust, using a single regex
instead of the overkill stripHTMLMedia(). The old implementation
has been moved into the Pystache code for now.
2020-01-10 14:59:29 +10:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00