anki/rslib/Cargo.toml

104 lines
2.7 KiB
TOML
Raw Normal View History

2019-12-23 05:42:14 +01:00
[package]
name = "anki"
version = "0.0.0"
2021-11-18 11:51:10 +01:00
edition = "2021"
authors = ["Ankitects Pty Ltd and contributors"]
license = "AGPL-3.0-or-later"
description = "Anki's Rust library code"
build = "build/main.rs"
[lib]
name = "anki"
path = "src/lib.rs"
[features]
bench = ["criterion"]
[[bench]]
name = "benchmark"
harness = false
required-features = ["bench"]
# After updating anything below, run ../cargo/update.py
[build-dependencies]
2021-11-18 11:54:00 +01:00
prost-build = "0.9.0"
[dev-dependencies]
2021-10-02 12:42:03 +02:00
env_logger = "0.9.0"
tokio = { version = "1.17", features = ["macros"] }
[dependencies]
# pinned as any changes could invalidate sqlite indexes
unicase = "=2.6.0"
2021-04-27 15:11:22 +02:00
tokio = { version = "1.17", features = ["fs", "rt-multi-thread"] }
2021-06-25 07:35:25 +02:00
anki_i18n = { path="i18n" }
criterion = { version = "0.3.5", optional = true }
2021-10-02 12:42:03 +02:00
nom = "7.0.0"
proc-macro-nested = "0.1.7"
slog-term = "2.8.0"
blake3 = "1.0.0"
bytes = "1.1.0"
2021-06-25 07:35:25 +02:00
chrono = "0.4.19"
coarsetime = "0.1.19"
2021-10-02 12:42:03 +02:00
flate2 = "1.0.22"
fluent = "0.16.0"
2021-06-25 07:35:25 +02:00
fluent-bundle = "0.15.1"
2021-10-02 12:42:03 +02:00
futures = "0.3.17"
2021-06-25 07:35:25 +02:00
hex = "0.4.3"
htmlescape = "0.3.1"
2021-06-25 07:35:25 +02:00
intl-memoizer = "0.5.1"
itertools = "0.10.1"
lazy_static = "1.4.0"
2021-10-02 12:42:03 +02:00
num_enum = "0.5.4"
2021-06-25 07:35:25 +02:00
num-integer = "0.1.44"
once_cell = "1.8.0"
2021-10-02 12:42:03 +02:00
pin-project = "1.0.8"
2021-11-18 11:54:00 +01:00
prost = "0.9.0"
2021-06-25 07:35:25 +02:00
rand = "0.8.4"
regex = "1.5.4"
reqwest = { git="https://github.com/ankitects/reqwest.git", rev="7591444614de02b658ddab125efba7b2bb4e2335", default-features=false, features=[
"json",
"socks",
"stream",
"multipart",
# the Bazel build scripts separate these out by platform
"native-tls",
"rustls-tls",
"rustls-tls-webpki-roots",
2021-06-18 10:15:41 +02:00
"rustls-tls-native-roots",
] }
rusqlite = { version = "0.26.1", features = ["trace", "functions", "collation", "bundled"] }
scopeguard = "1.1.0"
2021-10-02 12:42:03 +02:00
serde = "1.0.130"
serde_derive = "1.0.130"
serde_json = "1.0.68"
2021-06-25 07:35:25 +02:00
serde_repr = "0.1.7"
2020-07-12 03:38:25 +02:00
serde_tuple = "0.5.0"
2021-11-18 11:54:00 +01:00
serde-aux = "3.0.1"
sha1 = "0.6.0"
2021-06-25 08:22:21 +02:00
slog = { version = "2.7.0", features = ["max_level_trace", "release_max_level_debug"] }
2021-10-02 12:42:03 +02:00
slog-async = "2.7.0"
slog-envlogger = "2.2.0"
2021-06-25 07:35:25 +02:00
tempfile = "3.2.0"
2021-06-25 08:22:21 +02:00
unic-langid = { version = "0.9.0", features = ["macros"] }
2021-06-25 07:35:25 +02:00
unicode-normalization = "0.1.19"
utime = "0.3.1"
2021-06-25 08:22:21 +02:00
zip = { version = "0.5.13", default-features = false, features = ["deflate", "time"] }
2021-10-02 12:42:03 +02:00
async-trait = "0.1.51"
ammonia = "3.1.2"
pulldown-cmark = "0.8.0"
fnv = "1.0.7"
2021-11-18 11:54:00 +01:00
strum = { version = "0.23.0", features = ["derive"] }
2021-10-02 12:42:03 +02:00
tokio-util = { version = "0.6.8", features = ["io"] }
pct-str = { git="https://github.com/timothee-haudebourg/pct-str.git", rev="4adccd8d4a222ab2672350a102f06ae832a0572d" }
unic-ucd-category = "0.9.0"
V3 parent limits (#1638) * avoid repinning Rust deps by default * add id_tree dependency * Respect intermediate child limits in v3 * Test new behaviour of v3 counts * Rework v3 queue building to respect parent limits * Add missing did field to SQL query * Fix `LimitTreeMap::is_exhausted()` * Rework tree building logic https://github.com/ankitects/anki/pull/1638#discussion_r798328734 * Add timer for build_queues() * `is_exhausted()` -> `limit_reached()` * Move context and limits into `QueueBuilder` This allows for moving more logic into QueueBuilder, so less passing around of arguments. Unfortunately, some tests will require additional work to set up. * Fix stop condition in new_cards_by_position * Fix order gather order of new cards by deck * Add scheduler/queue/builder/burying.rs * Fix bad tree due to unsorted child decks * Fix comment * Fix `cap_new_to_review_rec()` * Add test for new card gathering * Always sort `child_decks()` * Fix deck removal in `cap_new_to_review_rec()` * Fix sibling ordering in new card gathering * Remove limits for deck total count with children * Add random gather order * Remove bad sibling order handling All routines ensure ascending order now. Also do some other minor refactoring. * Remove queue truncating All routines stop now as soon as the root limit is reached. * Move deck fetching into `QueueBuilder::new()` * Rework new card gather and sort options https://github.com/ankitects/anki/pull/1638#issuecomment-1032173013 * Disable new sort order choices ... depending on set gather order. * Use enum instead of numbers * Ensure valid sort order setting * Update new gather and sort order tooltips * Warn about random insertion order with v3 * Revert "Add timer for build_queues()" This reverts commit c9f5fc6ebe87953c17a0c842990b009b5596c69c. * Update rslib/src/storage/card/mod.rs (dae) * minor wording tweaks to the tooltips (dae) + move legacy strings to bottom + consistent capitalization (our leech action still needs fixing, but that will require introducing a new 'suspend card' string as the existing one is used elsewhere as well)
2022-02-10 00:55:43 +01:00
id_tree = "1.8.0"
Colpkg fixes (#1722) * Fix legacy colpkg import; disable v3 import/export; add roundtrip test The test has revealed we weren't decompressing the media files on v3 import. That's easy to fix, but means all files need decompressing even when they already exist, which is not ideal - it would be better to store size/checksum in the metadata instead. * Switch media and meta to protobuf; re-enable v3 import/export - Fixed media not being decompressed on import - The uncompressed size and checksum is now included for each media entry, so that we can quickly check if a given file needs to be extracted. We're still just doing a naive size comparison on colpkg import at the moment, but we may want to use a checksum in the future, and will need a checksum for apkg imports. - Checksums can't be efficiently encoded in JSON, so the media list has been switched to protobuf to reduce the the space requirements. - The meta file has been switched to protobuf as well, for consistency. This will mean any colpkg files exported with beta7 will be unreadable. * Avoid integer version comparisons * Re-enable v3 test * Apply suggestions from code review Co-authored-by: RumovZ <gp5glkw78@relay.firefox.com> * Add export_colpkg() method to Collection More discoverable, and easier to call from unit tests * Split import/export code out into separate folders Currently colpkg/*.rs contain some routines that will be useful for apkg import/export as well; in the future we can refactor them into a separate file in the parent module. * Return a proper error when media import fails This tripped me up when writing the earlier unit test - I had called the equivalent of import_colpkg()?, and it was returning a string error that I didn't notice. In practice this should result in the same text being shown in the UI, but just skips the tooltip. * Automatically create media folder on import * Move roundtrip test into separate file; check collection too * Remove zstd version suffix Prevents a warning shown each time Rust Analyzer is used to check the code. Co-authored-by: RumovZ <gp5glkw78@relay.firefox.com>
2022-03-17 06:11:23 +01:00
zstd = { version="0.10.0", features=["zstdmt"] }
Backups (#1685) * Add zstd dep * Implement backend backup with zstd * Implement backup thinning * Write backup meta * Use new file ending anki21b * Asynchronously backup on collection close in Rust * Revert "Add zstd dep" This reverts commit 3fcb2141d2be15f907269d13275c41971431385c. * Add zstd again * Take backup col path from col struct * Fix formatting * Implement backup restoring on backend * Normalize restored media file names * Refactor `extract_legacy_data()` A bit cumbersome due to borrowing rules. * Refactor * Make thinning calendar-based and gradual * Consider last kept backups of previous stages * Import full apkgs and colpkgs with backend * Expose new backup settings * Test `BackupThinner` and make it deterministic * Mark backup_path when closing optional * Delete leaky timer * Add progress updates for restoring media * Write restored collection to tempfile first * Do collection compression in the background thread This has us currently storing an uncompressed and compressed copy of the collection in memory (not ideal), but means the collection can be closed without waiting for compression to complete. On a large collection, this takes a close and reopen from about 0.55s to about 0.07s. The old backup code for comparison: about 0.35s for compression off, about 8.5s for zip compression. * Use multithreading in zstd compression On my system, this reduces the compression time of a large collection from about 0.55s to 0.08s. * Stream compressed collection data into zip file * Tweak backup explanation + Fix incorrect tab order for ignore accents option * Decouple restoring backup and full import In the first case, no profile is opened, unless the new collection succeeds to load. In the second case, either the old collection is reloaded or the new one is loaded. * Fix number gap in Progress message * Don't revert backup when media fails but report it * Tweak error flow * Remove native BackupLimits enum * Fix type annotation * Add thinning test for whole year * Satisfy linter * Await async backup to finish * Move restart disclaimer out of backup tab Should be visible regardless of the current tab. * Write restored collection in chunks * Refactor * Write media in chunks and refactor * Log error if removing file fails * join_backup_task -> await_backup_completion * Refactor backup.rs * Refactor backup meta and collection extraction * Fix wrong error being returned * Call sync_all() on new collection * Add ImportError * Store logger in Backend, instead of creating one on demand init_backend() accepts a Logger rather than a log file, to allow other callers to customize the logger if they wish. In the future we may want to explore using the tracing crate as an alternative; it's a bit more ergonomic, as a logger doesn't need to be passed around, and it plays more nicely with async code. * Sync file contents prior to rename; sync folder after rename. * Limit backup creation to once per 30 min * Use zstd::stream::copy_decode * Make importing abortable * Don't revert if backup media is aborted * Set throttle implicitly * Change force flag to minimum_backup_interval * Don't attempt to open folders on Windows * Join last backup thread before starting new one Also refactor. * Disable auto sync and backup when restoring again * Force backup on full download * Include the reason why a media file import failed, and the file path - Introduce a FileIoError that contains a string representation of the underlying I/O error, and an associated path. There are a few places in the code where we're currently manually including the filename in a custom error message, and this is a step towards a more consistent approach (but we may be better served with a more general approach in the future similar to Anyhow's .context()) - Move the error message into importing.ftl, as it's a bit neater when error messages live in the same file as the rest of the messages associated with some functionality. * Fix importing of media files * Minor wording tweaks * Save an allocation I18n strings with replacements are already strings, so we can skip the extra allocation. Not that it matters here at all. * Terminate import if file missing from archive If a third-party tool is creating invalid archives, the user should know about it. This should be rare, so I did not attempt to make it translatable. * Skip multithreaded compression on small collections Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2022-03-07 06:11:31 +01:00
num_cpus = "1.13.1"
CSV import/export fixes and features (#1898) * Fix footer moving upwards * Fix column detection Was broken because escaped line breaks were not considered. Also removes delimiter detection on `#columns:` line. User must use tabs or set delimiter beforehand. * Add CSV preview * Parse `#tags column:` * Optionally export deck and notetype with CSV * Avoid clones in CSV export * Prevent bottom of page appearing under footer (dae) * Increase padding to 1em (dae) With 0.5em, when a vertical scrollbar is shown, it sits right next to the right edge of the content, making it look like there's no right margin. * Experimental changes to make table fit+scroll (dae) - limit individual cells to 15em, and show ellipses when truncated - limit total table width to body width, so that inner table is shown with scrollbar - use class rather than id - ids are bad practice in Svelte components, as more than one may be displayed on a single page * Skip importing foreign notes with filtered decks Were implicitly imported into the default deck before. Also some refactoring to fetch deck ids and names beforehand. * Hide spacer below hidden field mapping * Fix guid being replaced when updating note * Fix dupe identity check Canonify tags before checking if dupe is identical, but only add update tags later if appropriate. * Fix deck export for notes with missing card 1 * Fix note lines starting with `#` csv crate doesn't support escaping a leading comment char. :( * Support import/export of guids * Strip HTML from preview rows * Fix initially set deck if current is filtered * Make isHtml toggle reactive * Fix `html_to_text_line()` stripping sound names * Tweak export option labels * Switch to patched rust-csv fork Fixes writing lines starting with `#`, so revert 5ece10ad05f331. * List column options with first column field * Fix flag for exports with HTML stripped
2022-06-09 02:28:01 +02:00
csv = { git="https://github.com/ankitects/rust-csv.git", rev="1c9d3aab6f79a7d815c69f925a46a4590c115f90" }