Merge lp:~jpakkane/mediascanner2/invalidatorfix into lp:mediascanner2

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 300
Merged at revision: 295
Proposed branch: lp:~jpakkane/mediascanner2/invalidatorfix
Merge into: lp:mediascanner2
Diff against target: 58 lines (+27/-0)
2 files modified
src/daemon/scannerdaemon.cc (+12/-0)
src/mediascanner/MediaStore.cc (+15/-0)
To merge this branch: bzr merge lp:~jpakkane/mediascanner2/invalidatorfix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marcus Tomlinson (community) Approve
Review via email: mp+247581@code.launchpad.net

Commit message

Send invalidations signals during scans that take a long time so the dash gets updated.

Description of the change

Send invalidations signals during scans that take a long time so the dash gets updated.

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

The jenkins node for the amd64 build failed, I've restarted a new ci run.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

If you run this on the device and tail -F mediascanner's log ever now and then it prints out an error about the database being locked. This seems to only happen when the scope is querying the database so it has one reader and one writer. Sqlite documentation says that this should be fully supported but it for some reason it does not work. Will investigate deeper.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
300. By Jussi Pakkanen

Use wal mode for the journal as it seems to work when there are multiple connections to the db.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

+1

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon/scannerdaemon.cc'
2--- src/daemon/scannerdaemon.cc 2014-10-22 21:08:00 +0000
3+++ src/daemon/scannerdaemon.cc 2015-01-27 13:35:55 +0000
4@@ -211,9 +211,21 @@
5
6 void ScannerDaemon::readFiles(MediaStore &store, const string &subdir, const MediaType type) {
7 Scanner s(extractor.get(), subdir, type);
8+ const int update_interval = 10; // How often to send invalidations.
9+ struct timespec previous_update, current_time;
10+ clock_gettime(CLOCK_MONOTONIC, &previous_update);
11+ previous_update.tv_sec -= update_interval/2; // Send the first update sooner for better visual appeal.
12 while(true) {
13 try {
14 auto d = s.next();
15+ clock_gettime(CLOCK_MONOTONIC, &current_time);
16+ while(g_main_context_pending(g_main_context_default())) {
17+ g_main_context_iteration(g_main_context_default(), FALSE);
18+ }
19+ if(current_time.tv_sec - previous_update.tv_sec >= update_interval) {
20+ invalidator.invalidate();
21+ previous_update = current_time;
22+ }
23 // If the file is broken or unchanged, use fallback.
24 if (store.is_broken_file(d.filename, d.etag)) {
25 fprintf(stderr, "Using fallback data for unscannable file %s.\n", d.filename.c_str());
26
27=== modified file 'src/mediascanner/MediaStore.cc'
28--- src/mediascanner/MediaStore.cc 2014-09-24 09:39:06 +0000
29+++ src/mediascanner/MediaStore.cc 2015-01-27 13:35:55 +0000
30@@ -42,6 +42,11 @@
31
32 using namespace std;
33
34+static int dummy_callback(void*, int , char**, char**) {
35+ return 0;
36+}
37+
38+
39 namespace mediascanner {
40
41 // Increment this whenever changing db schema.
42@@ -398,6 +403,16 @@
43 if(sqlite3_open_v2(filename.c_str(), &p->db, sqliteFlags, nullptr) != SQLITE_OK) {
44 throw runtime_error(sqlite3_errmsg(p->db));
45 }
46+ if(access == MS_READ_WRITE) {
47+ // The default journal mode does not seem to be safe but
48+ // instead gives out database locked errors when writing
49+ // and querying at the same time.
50+ char *err;
51+ sqlite3_exec(p->db, "PRAGMA journal_mode=WAL;", dummy_callback, nullptr, &err);
52+ if(err) {
53+ throw runtime_error(err);
54+ }
55+ }
56 register_tokenizer(p->db);
57 register_functions(p->db);
58 int detectedSchemaVersion = getSchemaVersion(p->db);

Subscribers

People subscribed via source and target branches