-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to work with desktop 2.1.54 code #11644
Commits on Jun 29, 2022
-
Squashes a few commits: Move the legacy schema toggle into BackendFactory Simplify backend handling; rework collection instantiation When the Rust code was initially introduced, it was not clear whether it would be usable on all devices, or whether it would need to be removed for some reason. This no doubt influenced the design of the existing API, which tries to make it easy to swap the Rust code out with something else. Unfortunately this approach has some downsides: - It makes it somewhat harder to follow, as method calls jump through multiple interfaces before they're actually sent to the backend. - It makes utilizing new methods considerably more cumbersome. For example, take the extract_av_tags() call. It follows the following path: collection method or method in related helper class: https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt#L242 to generic interface: https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/backend/DroidBackend.kt#L83 to specific implementation: https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidV16Backend.kt#L57 and if it's unusable with the legacy schema (which I don't believe is actually true in this case), it also needs to be added to the other implementation: https://github.com/ankidroid/Anki-Android/blob/cea79e1b077bc30e7eed8f37529002aae416d34d/AnkiDroid/src/main/java/com/ichi2/libanki/backend/RustDroidBackend.kt#L87 and then finally, a method in the backend module is invoked. The backend module has code generation so that invoking a backend method is as simple as making a method call, but currently you have to weave the call through 3 or so levels of indirection before you can actually use it. With something like 170 available methods, that's a fair amount of extra work required. Rather than trying to insulate libanki from the backend code, this PR drops some of the indirection in favour of the approach the desktop takes: libanki is the insulation layer; it can call freely into the backend methods, but consumers (eg the GUI code) are expected to only call methods on the collection, and not access the backend directly. In addition to the above, collection initialization has been reworked to be more similar to the computer version. Instead of the collection being created from a database object, a backend is passed into the collection creation, and the collection takes care of creating a DB instance that wraps the backend. Remove always-on isUsingRustBackend Drop the legacy upgrade/initialization code Schema 11 was introduced in 2012, and decks that still are <11 are very rare. The desktop dropped support for schema 10 back in early 2020. This also removes the need to modify SCHEMA_VERSION when switching between TESTING_USE_V16_BACKEND. Remove DOWNGRADE_REQUIRED and slightly simplify startup error handling - The backend automatically downgrades when required, and possible. No backup is required, as the downgrade happens in a single transaction, and the downgrade code has proven itself over time. - Store the type of failure in getColSafe(), so it can be checked later. Update to work with desktop 2.1.53 code Depends on ankidroid/Anki-Android-Backend#202 Due to the removal and change of a few backend methods, syncing, importing and the card templates screen will not work when the schema16 setting is active (actually schema18 now). To get them working again, those code paths will need to switch to the backend implementations. A few notes: - Downgrading happens automatically when loading the collection in schema11 mode, so the extra code dealing with downgrades & "can downgrade" reporting can be stripped. - Added the ability to run col.set_config("key", JSONObject.NULL), as unit tests were attempting to write the entire collection config, which is no longer supported. - All tests pass on both old and new backends, though the latter required disabling a few failed tests when running with the new schema (eg notetype updating). Integrates, and thus closes ankidroid#11579 and closes ankidroid#11581 Remove the time argument to Storage.collection() Collection does not currently take a time argument, and relies on the global object instead, so this change brings Storage in line with it. Reuse the backend when closing+reopening a collection Avoids having to re-initialize the translations, and reduces leaks (the import + export code leaks backends still)
Configuration menu - View commit details
-
Copy full SHA for ed221af - Browse repository at this point
Copy the full SHA ed221afView commit details -
Configuration menu - View commit details
-
Copy full SHA for fcf73ab - Browse repository at this point
Copy the full SHA fcf73abView commit details -
Configuration menu - View commit details
-
Copy full SHA for e76b814 - Browse repository at this point
Copy the full SHA e76b814View commit details -
Implement syncing with the backend
Login, regular syncs and full upload/download work with the new schema active, but currently only show progress on the console, and more work will be required to polish this up. I have no previous experience with Kotlin co-routines, so this may not be following best practice.
Configuration menu - View commit details
-
Copy full SHA for 113db83 - Browse repository at this point
Copy the full SHA 113db83View commit details -
Don't store collection reference in DeckTreeNode
Pass it in to processChildren() instead, which is cleaner, and will work better with the move to a backend method. Speed up deck list by rendering it with the backend This delegates to the backend to render the deck tree, instead of calculating it in Java. On @Arthur-Milchior's large collection with the daily limits turned up, the speed difference in an x86_64 sim is dramatic: 2.4s with the old Java code, and 70ms with the new Rust code. - Make deckDueList() private; switch callers to use deckDueTree() The backend only provides a deckDueTree(), and switching the calls to deckDueList() now will make migration easier in the future. Squashed from ankidroid#11599
Configuration menu - View commit details
-
Copy full SHA for fc18e24 - Browse repository at this point
Copy the full SHA fc18e24View commit details -
Add some new flags to local.properties
legacy_schema=false: use the new backend code by default local_backend=true: use a locally built copy of the backend fatal_warnings=false: don't fail the build on Kotlin warning
Configuration menu - View commit details
-
Copy full SHA for 4615edc - Browse repository at this point
Copy the full SHA 4615edcView commit details -
Expose card info/graph methods
To enable krmanik#23 Also requires ankidroid/Anki-Android-Backend@4c3eea4 or similar
Configuration menu - View commit details
-
Copy full SHA for aa387d2 - Browse repository at this point
Copy the full SHA aa387d2View commit details -
Use named args in backend calls
This will ensure any reordering or removal of args in the proto files in the future will not lead to incorrect arguments being passed in. + Fix copyright year
Configuration menu - View commit details
-
Copy full SHA for 2d944c7 - Browse repository at this point
Copy the full SHA 2d944c7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5fd5d23 - Browse repository at this point
Copy the full SHA 5fd5d23View commit details -
Configuration menu - View commit details
-
Copy full SHA for 40aee91 - Browse repository at this point
Copy the full SHA 40aee91View commit details -
Add support for colpkg import/export & backups
+ Backup before full download
Configuration menu - View commit details
-
Copy full SHA for dc98ce2 - Browse repository at this point
Copy the full SHA dc98ce2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6bc984f - Browse repository at this point
Copy the full SHA 6bc984fView commit details -
Remove some unnecessary DB queries when legacy schema disabled
- collapsed + filtered status is included in the deck list from the backend, so does not need to be looked up for each row - cache the current deck id at deck list build time, so it doesn't need to be looked up for every row (applies to old schema too) - skip default deck logic, which is handled by backend
Configuration menu - View commit details
-
Copy full SHA for 3f3a1c9 - Browse repository at this point
Copy the full SHA 3f3a1c9View commit details -
Add mention of TRACESQL env var for debugging
This became usable in AnkiDroid after we starting capturing stdout.
Configuration menu - View commit details
-
Copy full SHA for f857ee1 - Browse repository at this point
Copy the full SHA f857ee1View commit details -
Add code to import/export apkg files via the backend
Also add ChangeManager Also demonstrates use of backend translations
Configuration menu - View commit details
-
Copy full SHA for b114e97 - Browse repository at this point
Copy the full SHA b114e97View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8c2fc8c - Browse repository at this point
Copy the full SHA 8c2fc8cView commit details -
Restrict backend logging to sync actions
Previously debug lines from third-party modules were also being included, and the HTTP library was leaking the sync key into the logs. Requires the latest commit to the -Backend repo PR.
Configuration menu - View commit details
-
Copy full SHA for c14b217 - Browse repository at this point
Copy the full SHA c14b217View commit details -
Configuration menu - View commit details
-
Copy full SHA for f4f0d16 - Browse repository at this point
Copy the full SHA f4f0d16View commit details -
Configuration menu - View commit details
-
Copy full SHA for d6a1a36 - Browse repository at this point
Copy the full SHA d6a1a36View commit details -
Configuration menu - View commit details
-
Copy full SHA for bb0dc2e - Browse repository at this point
Copy the full SHA bb0dc2eView commit details