Merge lp://qastaging/~tkluck/simple-scan/autosaves into lp://qastaging/~simple-scan-team/simple-scan/trunk
- autosaves
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 602 |
Proposed branch: | lp://qastaging/~tkluck/simple-scan/autosaves |
Merge into: | lp://qastaging/~simple-scan-team/simple-scan/trunk |
Diff against target: |
635 lines (+545/-2) 6 files modified
.bzrignore (+1/-0) configure.ac (+1/-0) src/Makefile.am (+4/-2) src/autosave-manager.vala (+521/-0) src/page.vala (+9/-0) src/ui.vala (+9/-0) |
To merge this branch: | bzr merge lp://qastaging/~tkluck/simple-scan/autosaves |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Ancell | Needs Fixing | ||
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
Hi Robert,
Thanks for your detailed feedback.
> The patch seems generally good, but I'm not able to confirm it working. I can confirm the database gets written, but if I do a "killall -9 simple-scan" and then restart it the existing book is not recovered. What steps should I take to confirm the patch works?
I don't have access to a scanner atm, so I cannot make a document like you're doing. However, it did work for me as far as I remember. What does work for me right now, is to add an autosave page manually, by
sqlite3 ~/.cache/
INSERT INTO "pages" VALUES(
and then starting simple-scan. The window will open with a very colourful page. Can you confirm that this works for you?
I will put your other remarks into work soon.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
Hi Timo,
If you ever want to test simple-scan you can pass the name of the scanner as an argument to simple-scan. Conveniently SANE has a test driver so the following:
$ simple-scan test
Works without any scanner attached!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
If you ever want to test simple-scan you can pass the name of the scanner as an argument to simple-scan. Conveniently SANE has a test driver so the following:
$ simple-scan test
Works without any scanner attached!
Thanks, that's very helpful! I now see that the first scanned page is not correctly stored in the database. The next one is, and it is also being correctly recovered on my machine. A clue is that I'm getting some of those warn_if_fails failing. Are you seeing the same behaviour?
I will have to look into it later.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
I've pushed some changes that seem to deal with the issues I could reproduce. Can you test the new version?
- 563. By Timo Kluck
-
Correctly deal with the pages that exist already when the autosave manager is started
- 564. By Timo Kluck
-
use a scan_finished signal to know when to autosave
- 565. By Timo Kluck
-
do not use curly braces for single line branches
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
I tried the following:
1. Run simple-scan with test driver:
bob@alchemy:
2. Scan a single page with text mode
3. Kill simple-scan with 'killall simple-scan':
Terminated
4. Run simple-scan again
bob@alchemy:
** (simple-scan:8023): CRITICAL **: autosave_
Doesn't recover the book and gives the above error.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
> I tried the following:
>
> 1. Run simple-scan with test driver:
> bob@alchemy:
> 2. Scan a single page with text mode
> 3. Kill simple-scan with 'killall simple-scan':
> Terminated
> 4. Run simple-scan again
> bob@alchemy:
>
> ** (simple-scan:8023): CRITICAL **: autosave_
> `SQLITE_OK == _tmp8_' failed
>
> Doesn't recover the book and gives the above error.
I'm doing the exact same thing (either first removing ~/.cache/
Could you help me debug this? There's no way I can do that without seeing it happen for myself. Can you recover the exit code of the prepare_v2 call? And can you recover the sql string after it has been formatted?
Thanks!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
Could you update it to log the error codes? That way it will be safer in the future.
- 566. By Timo Kluck
-
add verbose logging output for autosave manager database access
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
I've just pushed a version that logs all the query strings and the resulting error codes. It would be great if you could send me the resulting logfile. (don't forget to specify --debug on the command line).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
It doesn't crash anymore but I get the following error:
[+0.00s] DEBUG: simple-
[+0.00s] DEBUG: Connecting to session manager
[+0.03s] WARNING: g_object_
[+0.03s] DEBUG: ui.vala:1463: Restoring window to 774x607 pixels
[+0.03s] DEBUG: ui.vala:1468: Restoring window to maximized
[+0.03s] DEBUG: autosave-
CREATE TABLE IF NOT EXISTS pages (
id integer PRIMARY KEY,
dpi integer,
)"
[+0.04s] DEBUG: autosave-
"
[+0.04s] DEBUG: autosave-
[+0.23s] DEBUG: autosave-
SELECT process_id,
id
FROM pages
WHERE process_id = 5391
AND book_revision = (
)
ORDER BY page_number
"
[+0.23s] WARNING: autosave-
[+0.28s] DEBUG: scanner.vala:1419: sane_init () -> SANE_STATUS_GOOD
[+0.28s] DEBUG: scanner.vala:1425: SANE version 1.0.23
[+0.28s] DEBUG: scanner.vala:1486: Requesting redetection of scan devices
[+0.28s] DEBUG: scanner.vala:776: Processing request
[+2.69s] DEBUG: scanner.vala:338: sane_get_devices () -> SANE_STATUS_GOOD
[+3.30s] DEBUG: scanner.vala:1559: Stopping scan thread
[+3.30s] DEBUG: scanner.vala:776: Processing request
[+3.31s] DEBUG: scanner.vala:1567: sane_exit ()
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
It seems to be this part - removing it makes it work.
AND book_revision = ( SELECT MAX(book_revision) WHERE process_id = 5391 )
Is a particular version of SQLite required for this syntax to be supported?
- 567. By Timo Kluck
-
Fix subquery
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
I could reproduce this error now (!). I'm surprised that it worked before, because the subquery misses a FROM clause. I just pushed a fix. Can you let me know your results?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
That fixes that error, but still not books being restored.
I am running the following:
1. $ simple-scan test -d
2. Pressing scan
3. Killing simple-scan with ctrl-C (or killall simple-scan)
4. $ simple-scan
No pages are restored.
Can you add some debugging messages that note what the the autosave manager is doing? I would expect to see the following in the log
"Restoring book with 5 pages"
"No book to restore"
"Failed to restore book: Error Sqlite.ERROR when getting pages"
"Autosaving book to ~/.cache/
- 568. By Timo Kluck
-
even more verbose logging
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
I just pushed some extra verbose logging. Could you post your log for when it is failing? And, just to make sure, can you also
rm -rf ~/.cache/
before testing?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
Did the following:
0. $ ~/.cache/
1. $ simple-scan test
2. Pressing scan
3. Ctrl+C
4. $ simple-scan
It worked some times but not always. The log from a failure is:
[+0.00s] DEBUG: simple-
[+0.00s] DEBUG: Connecting to session manager
[+0.04s] WARNING: g_object_
[+0.04s] DEBUG: ui.vala:1463: Restoring window to 774x607 pixels
[+0.04s] DEBUG: autosave-
[+0.04s] DEBUG: autosave-
CREATE TABLE IF NOT EXISTS pages (
id integer PRIMARY KEY,
dpi integer,
)"
[+0.06s] DEBUG: autosave-
"
[+0.06s] DEBUG: autosave-
[+0.06s] DEBUG: autosave-
[+0.06s] DEBUG: autosave-
SELECT process_id,
id
FROM pages
WHERE process_id = 11515
AND book_revision = (
)
ORDER BY page_number
"
[+0.06s] DEBUG: autosave-
[+0.06s] DEBUG: autosave-
[+0.06s] DEBUG: autosave-
[+0.10s] DEBUG: scanner.vala:1419: sane_init () -> SANE_STATUS_GOOD
[+0.10s] DEBUG: scanner.vala:1425: SANE version 1.0.23
[+0.10s] DEBUG: scanner.vala:1486: Requesting redetection of scan devices
[+0....
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
Log when the database was created:
[+0.00s] DEBUG: simple-
[+0.00s] DEBUG: Connecting to session manager
[+0.03s] WARNING: g_object_
[+0.03s] DEBUG: ui.vala:1463: Restoring window to 774x607 pixels
[+0.03s] DEBUG: autosave-
[+0.03s] DEBUG: autosave-
CREATE TABLE IF NOT EXISTS pages (
id integer PRIMARY KEY,
dpi integer,
)"
[+0.23s] DEBUG: autosave-
"
[+0.23s] DEBUG: autosave-
[+0.23s] DEBUG: autosave-
[+0.23s] DEBUG: autosave-
[+0.23s] DEBUG: autosave-
INSERT INTO pages
0)
"
[+0.39s] DEBUG: autosave-
[+0.39s] DEBUG: autosave-
UPDATE pages
SET
"
[+0.58s] DEBUG: scanner.vala:1419: sane_init () -> SANE_STATUS_GOOD
[+0.58s] DEBUG: scanner.vala:1425: SANE version 1.0.23
[+0.58s] DEBUG: scanner.vala:1486: Requesting redetection of scan devices
[+0.58s] DEBUG: scanner.vala:776: Processing request
[+1.73s] DEBUG: simple-
[+1.73s] DEBUG: scanner.vala:1532: Scanner.scan ("test", dpi=150, scan_mode=
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
I think I've got it. The book_hash parameter may be formatted as a signed
int by vala into the query, and then it doesn't match unsigned value in the
record.
I'll do the proper thing and use bind_int for these things. I'll let you
know as soon as I've pushed an updated version.
Thanks for the extensive logs and testing!
- 569. By Timo Kluck
-
use bind_int64 for the direct_hash values
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Timo Kluck (tkluck) wrote : | # |
Could you test again? I could reproduce the problems with your database but I can't generate the same erroneous database on my machine, so I can't be 100% sure this last commit tackled the problem.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Ancell (robert-ancell) wrote : | # |
Pushed with some coding style changes, thanks for the patience!
Hi,
Thanks for working on this!
The patch seems generally good, but I'm not able to confirm it working. I can confirm the database gets written, but if I do a "killall -9 simple-scan" and then restart it the existing book is not recovered. What steps should I take to confirm the patch works?
> // FIXME: this only works on linux spawn_command_ line_sync ("pidof simple-scan | sed \"s/ /,/g\"", out current_pids);
> string current_pids;
> Process.
This is a bit gross, but don't know if we can get around it.
> public void on_page_changed (Page page)
> {
> /* we don't update the database as it is to slow to do so each time
> * a scan line is received.
> */
> //update_page (page);
> }
Please remove this if it doesn't do anything.
> if (number_ of_instances > 0)
> {
> assert_not_reached ();
> }
We don't use curly braces if there's just one line in a branch.
> /* FIXME: we would like to connect to a scan_fished signal on a page,
> * but it does not exist. Updating the database every time a scanline
> * has changed is much to slow. We choose to update the database every
> * now and then, instead.
Let's add that signal then.