zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #05194
[Merge] lp:~zeitgeist/zeitgeist/fix-950983 into lp:zeitgeist
Seif Lotfy has proposed merging lp:~zeitgeist/zeitgeist/fix-950983 into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
Related bugs:
Bug #950983 in Zeitgeist Framework: "Storage monitor sets up weird storage ids"
https://bugs.launchpad.net/zeitgeist/+bug/950983
For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/fix-950983/+merge/98176
Replaced the INSERT OR REPLACE statement with a INSERT and an UPDATE statement to fix bug 950983
--
https://code.launchpad.net/~zeitgeist/zeitgeist/fix-950983/+merge/98176
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~zeitgeist/zeitgeist/fix-950983 into lp:zeitgeist.
=== modified file 'extensions/storage-monitor.vala'
--- extensions/storage-monitor.vala 2012-02-10 13:35:02 +0000
+++ extensions/storage-monitor.vala 2012-03-19 10:07:31 +0000
@@ -112,8 +112,10 @@
private Sqlite.Statement get_storages_stmt;
private Sqlite.Statement store_storage_medium_stmt;
+ private Sqlite.Statement update_storage_medium_stmt;
private Sqlite.Statement insert_unavailable_medium_stmt;
private Sqlite.Statement update_medium_state_stmt;
+ private Sqlite.Statement get_storage_medium_id_stmt;
private NetworkMonitor network;
private uint watch_connman;
@@ -236,7 +238,7 @@
database.assert_query_success (rc, "Storage retrieval query error");
sql = """
- INSERT OR REPLACE INTO storage (
+ INSERT INTO storage (
value, state, icon, display_name
) VALUES (
?, ?, ?, ?
@@ -245,6 +247,14 @@
database.assert_query_success (rc, "Storage insertion query error");
sql = """
+ UPDATE storage SET
+ state=?, icon=?, display_name=?
+ WHERE value=?
+ """;
+ rc = db.prepare_v2 (sql, -1, out update_storage_medium_stmt);
+ database.assert_query_success (rc, "Storage update query error");
+
+ sql = """
INSERT INTO storage (
state, value
) VALUES (
@@ -262,6 +272,13 @@
rc = db.prepare_v2 (sql, -1, out update_medium_state_stmt);
database.assert_query_success (rc,
"update_medium_state_stmt error");
+
+ sql = """
+ SELECT id FROM storage WHERE value=?
+ """;
+ rc = db.prepare_v2 (sql, -1, out get_storage_medium_id_stmt);
+ database.assert_query_success (rc,
+ "get_storage_medium_id_stmt error");
}
public override void pre_insert_events (GenericArray<Event?> events,
@@ -355,15 +372,31 @@
string display_name)
{
debug ("VOLUME ADDED: %s".printf(medium_name));
- store_storage_medium_stmt.reset ();
- store_storage_medium_stmt.bind_text (1, medium_name);
- store_storage_medium_stmt.bind_int (2, 1);
- store_storage_medium_stmt.bind_text (3, icon);
- store_storage_medium_stmt.bind_text (4, display_name);
- int rc = store_storage_medium_stmt.step ();
- database.assert_query_success (rc, "add_storage_medium",
- Sqlite.DONE);
+ get_storage_medium_id_stmt.reset ();
+ get_storage_medium_id_stmt.bind_text (1, medium_name);
+ if (get_storage_medium_id_stmt.step () == Sqlite.ROW)
+ {
+ update_storage_medium_stmt.reset ();
+ update_storage_medium_stmt.bind_int (1, 1);
+ update_storage_medium_stmt.bind_text (2, icon);
+ update_storage_medium_stmt.bind_text (3, display_name);
+ update_storage_medium_stmt.bind_text (4, medium_name);
+ int rc = update_storage_medium_stmt.step ();
+ database.assert_query_success (rc, "update_storage_medium",
+ Sqlite.DONE);
+ }
+ else
+ {
+ store_storage_medium_stmt.reset ();
+ store_storage_medium_stmt.bind_text (1, medium_name);
+ store_storage_medium_stmt.bind_int (2, 1);
+ store_storage_medium_stmt.bind_text (3, icon);
+ store_storage_medium_stmt.bind_text (4, display_name);
+ int rc = store_storage_medium_stmt.step ();
+ database.assert_query_success (rc, "add_storage_medium",
+ Sqlite.DONE);
+ }
storage_available (medium_name, StorageMedia.to_variant (
medium_name, true, icon, display_name));
Follow ups