Commit graph

3616 commits

Author SHA1 Message Date
Damien Elmes
28defd2b3c ensure id list not empty 2020-03-20 21:15:23 +10:00
Damien Elmes
02af7b2ab1 decode search terms in parser 2020-03-20 21:15:23 +10:00
Damien Elmes
c12ebc6124 split up searches with a qualifier 2020-03-20 21:15:23 +10:00
Damien Elmes
43f21b8135 basic search parsing 2020-03-20 21:15:23 +10:00
Damien Elmes
82dbbe7211 add string about waiting for completion 2020-03-20 21:15:23 +10:00
Damien Elmes
2ea17d272c wait for media sync to complete before unloading collection 2020-03-20 21:15:23 +10:00
Damien Elmes
5a20d9da79 release mutex before beginning media sync
And check media sync is not running on close
2020-03-20 21:15:23 +10:00
Damien Elmes
a321efe9db fix media sync being logged to console 2020-03-20 21:15:23 +10:00
Damien Elmes
ae42885ee2 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
e980d20a40 reuse the existing backend instead of creating a new one 2020-03-20 21:15:23 +10:00
Damien Elmes
5aba5c3ab9 drop the separate i18n backend 2020-03-20 21:15:23 +10:00
Damien Elmes
e5f883d1c3 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
c710580604 move media folder/db paths into collection
this breaks background media syncing for now
2020-03-20 21:15:23 +10:00
Damien Elmes
8c8674f57b drop unused col_path 2020-03-20 21:15:23 +10:00
Damien Elmes
3cacc00fc3 make the collection optional 2020-03-20 21:15:23 +10:00
Damien Elmes
90a44509be drop usage of flushSched() 2020-03-20 21:15:23 +10:00
Damien Elmes
fa527bca4f import .colpkg in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
8c6e2cdb82 import .apkg files in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
128b45aa40 import mapped files like csv in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
37b24bf782 export in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
e53ee52d2a remove db.close() 2020-03-20 21:15:23 +10:00
Damien Elmes
258a8282d4 move .reopen() to mw; fix exporting 2020-03-20 21:15:23 +10:00
Damien Elmes
07381f74e6 fix mypy warning 2020-03-20 21:15:23 +10:00
Damien Elmes
a02c4ed994 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
cd78da24d9 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
df33b04be8 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
d4df98c90f release the GIL during a DB request 2020-03-20 21:15:23 +10:00
Damien Elmes
8cb3ed7435 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
3256c74409 pass weakref in from storage to fix type checking/code completion 2020-03-20 21:15:23 +10:00
Damien Elmes
116f7fa3f1 support first_row_only 2020-03-20 21:15:23 +10:00
Damien Elmes
7e5f713f05 proper implementation of executemany(); drop executescript() 2020-03-20 21:15:23 +10:00
Damien Elmes
121687ea91 wrap the collection in a mutex so DB access is thread safe 2020-03-20 21:15:23 +10:00
Damien Elmes
e72d21e09e move note code into notes.rs, add ability to rollback when unchanged 2020-03-20 21:15:23 +10:00
Damien Elmes
3f3a45e2ba 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
700d713f80 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
0147d9e470 drop log= argument from Collection 2020-03-20 21:15:23 +10:00
Damien Elmes
70c7cde2cd remove remaining db kwargs 2020-03-20 21:15:23 +10:00
Damien Elmes
d42df6e0f1 add a temporary executemany() 2020-03-20 21:15:23 +10:00
Damien Elmes
bd7ded18c3 drop the protobuf prototype 2020-03-20 21:15:23 +10:00
Damien Elmes
38d4ea5311 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
a129b8f8cf 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
1db876ba1c tweak db type hints 2020-03-20 21:15:23 +10:00
Damien Elmes
7fbc229dcd drop usage of pysqlite Cursor 2020-03-20 21:15:23 +10:00
Damien Elmes
e5a465cccb tweak layout of db methods 2020-03-20 21:15:23 +10:00
Damien Elmes
7bf27febe6 drop .cursor() 2020-03-20 21:15:23 +10:00
Damien Elmes
fb9db72dde use total_changes() sqlite func 2020-03-20 21:15:23 +10:00
Damien Elmes
45bc1cd73e drop the schema <11 upgrade code 2020-03-20 21:15:23 +10:00
Damien Elmes
fcfe1bd66c drop context manager 2020-03-20 21:15:23 +10:00
Damien Elmes
9e67ea736a drop named sql arguments 2020-03-20 21:15:23 +10:00
Damien Elmes
6d0c84a1e9 drop progress handler and timeout arg 2020-03-20 21:15:23 +10:00