mirror of
https://github.com/ankitects/anki.git
synced 2025-11-28 07:27:13 -05:00
The undo code was using triggers and a temporary table to write out all changed rows before making a change. This made for powerful undo/redo support, but had some problems: - creating the tables and triggers wasn't cheap, especially on mobile devices - likewise, every data modification required writing into two separate databases, almost doubling the amount of writes required - it was possible to leave the DB in an inconsistent state if an undoable operation is followed by a non-undoable operation that references the undoable operation, and the user then rolls back the undoable operation. To address these issues, we simplify undo by integrating it with the autosave changes: - .save() can be passed a name to mark a rollback point. If the user undoes the change, any changes since the last save are lost - autosaves happen every 5 minutes, and are pushed back on a .save(), so the maximum work a user can lose is 5 minutes. - reviews are handled separately, so we can let the user undo multiple reviews at once - if necessary, special cases could be added for other operations like marking This means that if a user does two damaging operations in a row they won't be able to restore the first one, but such an event is both unlikely, and is also covered by the backups made each time a deck is opened. |
||
|---|---|---|
| .. | ||
| importing | ||
| template | ||
| __init__.py | ||
| cards.py | ||
| consts.py | ||
| cram.py | ||
| db.py | ||
| deck.py | ||
| errors.py | ||
| exporting.py | ||
| facts.py | ||
| find.py | ||
| graphs.py | ||
| groups.py | ||
| hooks.py | ||
| js.py | ||
| lang.py | ||
| latex.py | ||
| media.py | ||
| models.py | ||
| sched.py | ||
| sound.py | ||
| stats.py | ||
| stdmodels.py | ||
| storage.py | ||
| sync.py | ||
| utils.py | ||