Commit Graph

3816 Commits

Author SHA1 Message Date
Damien Elmes
d7daa63dbd make sure we set db to None so we can tell when we've closed the DB 2020-03-20 21:15:23 +10:00
Damien Elmes
d03e13a1bd reuse the existing backend instead of creating a new one 2020-03-20 21:15:23 +10:00
Damien Elmes
ba17567617 drop the separate i18n backend 2020-03-20 21:15:23 +10:00
Damien Elmes
874bc085fe support opening and closing the DB while keeping backend alive
This is safer than just dropping the backend, as .close() will
block if something else is holding the mutex. Also means we can
drop the extra I18nBackend code.

Media syncing still needs fixing.
2020-03-20 21:15:23 +10:00
Damien Elmes
94e4c40ebf move media folder/db paths into collection
this breaks background media syncing for now
2020-03-20 21:15:23 +10:00
Damien Elmes
649b40371b drop unused col_path 2020-03-20 21:15:23 +10:00
Damien Elmes
1322d8c617 make the collection optional 2020-03-20 21:15:23 +10:00
Damien Elmes
d0d6aa1433 drop usage of flushSched() 2020-03-20 21:15:23 +10:00
Damien Elmes
8d429cd192 import .colpkg in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
ad9dad8748 import .apkg files in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
231fa30a86 import mapped files like csv in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
53952ba131 export in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
7986a79530 remove db.close() 2020-03-20 21:15:23 +10:00
Damien Elmes
fa12213e98 move .reopen() to mw; fix exporting 2020-03-20 21:15:23 +10:00
Damien Elmes
fe59d11047 fix mypy warning 2020-03-20 21:15:23 +10:00
Damien Elmes
0f38514ad7 drop the DB progress handler code
This code was an awful hack to provide some semblance of UI
responsiveness while executing DB statements on the main thread.
Instead, we can just run DB statements in a background thread now,
keeping the UI responsive.
2020-03-20 21:15:23 +10:00
Damien Elmes
90d4d62c48 use a timer to automatically show progress window
We were previously relying on the DB progress hook to cause the
progress window to display.

Qt's progress dialogs do have built in support for automatically
showing, but it's easier to add a timer than change the existing
code to use it.
2020-03-20 21:15:23 +10:00
Damien Elmes
32555b2857 run Check DB in a background thread
Since the DB is now stored behind a mutex, we're no longer limited
to accessing the database on the main thread.
2020-03-20 21:15:23 +10:00
Damien Elmes
daaf8bdc70 release the GIL during a DB request 2020-03-20 21:15:23 +10:00
Damien Elmes
90de4a267d drop lock() and setAutocommit()
We no longer need to worry about pysqlite implicitly beginning
transactions, and can be more explicit about beginning/ending
transactions

save() now also has a trx argument controlling whether a
transaction should be started / left open
2020-03-20 21:15:23 +10:00
Damien Elmes
63e3357068 pass weakref in from storage to fix type checking/code completion 2020-03-20 21:15:23 +10:00
Damien Elmes
db1508e27c support first_row_only 2020-03-20 21:15:23 +10:00
Damien Elmes
e14c5e4745 proper implementation of executemany(); drop executescript() 2020-03-20 21:15:23 +10:00
Damien Elmes
14546c8a8b wrap the collection in a mutex so DB access is thread safe 2020-03-20 21:15:23 +10:00
Damien Elmes
47c142a74c move note code into notes.rs, add ability to rollback when unchanged 2020-03-20 21:15:23 +10:00
Damien Elmes
ae06b9e446 add Collection struct, and get media check working again
- media check no longer needs collection to be closed
- use savepoints for operations initiated by Rust, so they are
atomic without forcing a commit
2020-03-20 21:15:23 +10:00
Damien Elmes
2cd7885ec0 add begin/commit/rollback, and support creating collections
all but one unit test is now passing
2020-03-20 21:15:23 +10:00
Damien Elmes
6db4418f05 drop log= argument from Collection 2020-03-20 21:15:23 +10:00
Damien Elmes
818401e464 remove remaining db kwargs 2020-03-20 21:15:23 +10:00
Damien Elmes
874ee80a68 add a temporary executemany() 2020-03-20 21:15:23 +10:00
Damien Elmes
b51e575a9d drop the protobuf prototype 2020-03-20 21:15:23 +10:00
Damien Elmes
b876d97770 use (or)json for DB bridge
Some initial testing with orjson indicates performance varies from
slightly better than pysqlite to about 2x slower depending on the type
of query.

Performance could be improved by building the Python list in rspy
instead of sending back json that needs to be decoded, but it may make
more sense to rewrite the hotspots in Rust instead. More testing is
required in any case.
2020-03-20 21:15:23 +10:00
Damien Elmes
04ca8ec038 initial work on DB handling in Rust
committing the Protobuf implementation for posterity, but will replace
it with json, as Protobuf measures about 6x slower for some workloads
like 'select * from notes'
2020-03-20 21:15:23 +10:00
Damien Elmes
77cf7dd4b7 tweak db type hints 2020-03-20 21:15:23 +10:00
Damien Elmes
b5c6134d80 drop usage of pysqlite Cursor 2020-03-20 21:15:23 +10:00
Damien Elmes
0b1d96fce0 tweak layout of db methods 2020-03-20 21:15:23 +10:00
Damien Elmes
5778459d7c drop .cursor() 2020-03-20 21:15:23 +10:00
Damien Elmes
87415c0d7f use total_changes() sqlite func 2020-03-20 21:15:23 +10:00
Damien Elmes
5f442ae95e drop the schema <11 upgrade code 2020-03-20 21:15:23 +10:00
Damien Elmes
527d269681 drop context manager 2020-03-20 21:15:23 +10:00
Damien Elmes
f4d4078537 drop named sql arguments 2020-03-20 21:15:23 +10:00
Damien Elmes
c8b9afac0c drop progress handler and timeout arg 2020-03-20 21:15:23 +10:00
Damien Elmes
8ef28f8571 drop echo and text factory 2020-03-20 21:15:23 +10:00
Damien Elmes
c1252d68f0 clone db.py into dbproxy.py 2020-03-20 21:15:23 +10:00
Damien Elmes
0d43e9dca3 tweak add-on wording 2020-03-20 21:00:21 +10:00
Damien Elmes
b7c64aaf39
Merge pull request #517 from Arthur-Milchior/backup_is_done
hook backup_is_done
2020-03-20 20:56:33 +10:00
Damien Elmes
f274e85edf
Merge pull request #470 from Arthur-Milchior/accept_card
Hook to decide whether a note should be added.
2020-03-20 20:56:04 +10:00
Damien Elmes
a80cafb3cf
Merge pull request #514 from evandroforks/box-sizing_border-box
Added box-sizing: border-box; to typeans by default
2020-03-20 20:50:40 +10:00
Damien Elmes
b2aa0756c9
Merge pull request #516 from Arthur-Milchior/hook_models_advanced_will_show
Hook models_advanced_will_show
2020-03-20 20:42:14 +10:00
Damien Elmes
7538ebcdf1
Merge pull request #518 from Arthur-Milchior/time_format_in_browser
Browser introduce method time_format
2020-03-20 20:37:57 +10:00