zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #04933
[Branch ~zeitgeist/zeitgeist/bluebird] Rev 408: Make sure we clean up transactions properly
------------------------------------------------------------
revno: 408
fixes bug: https://launchpad.net/bugs/937991
committer: Michal Hruby <michal.mhr@xxxxxxxxx>
branch nick: bluebird
timestamp: Tue 2012-02-21 19:17:16 +0100
message:
Make sure we clean up transactions properly
modified:
src/engine.vala
src/sql.vala
--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'src/engine.vala'
--- src/engine.vala 2012-02-10 13:35:02 +0000
+++ src/engine.vala 2012-02-21 18:17:16 +0000
@@ -72,13 +72,24 @@
extension_collection.call_pre_insert_events (events, sender);
uint32[] event_ids = new uint32[events.length];
+ EngineError? err = null;
database.begin_transaction ();
- for (int i = 0; i < events.length; ++i)
- {
- if (events[i] != null)
- event_ids[i] = insert_event (events[i]);
- }
- database.end_transaction ();
+ try
+ {
+ for (int i = 0; i < events.length; ++i)
+ {
+ if (events[i] != null)
+ event_ids[i] = insert_event (events[i]);
+ }
+ database.end_transaction ();
+ }
+ catch (EngineError e)
+ {
+ err = e;
+ database.abort_transaction ();
+ }
+ if (err != null) throw err;
+
extension_collection.call_post_insert_events (events, sender);
return event_ids;
}
=== modified file 'src/sql.vala'
--- src/sql.vala 2012-02-10 11:28:05 +0000
+++ src/sql.vala 2012-02-21 18:17:16 +0000
@@ -277,6 +277,12 @@
assert_query_success (rc, "Can't commit transaction");
}
+ public void abort_transaction () throws EngineError
+ {
+ int rc = database.exec ("ROLLBACK");
+ assert_query_success (rc, "Can't rollback transaction");
+ }
+
public void close ()
{
// SQLite connection is implicitly closed upon destruction