aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service
diff options
context:
space:
mode:
authorhrxi <hrrrxi@gmail.com>2019-09-01 18:18:25 +0200
committerfiaxh <fiaxh@users.noreply.github.com>2019-09-10 19:36:11 +0200
commitd5d305193ce527f1cc3022c406de35d9a85d4ccb (patch)
treed12efc741319a7d71c13f7bf6c2c7579d25fdabe /libdino/src/service
parent9950742bf1903291c271619aea101b0e2f81d19c (diff)
downloaddino-d5d305193ce527f1cc3022c406de35d9a85d4ccb.tar.gz
dino-d5d305193ce527f1cc3022c406de35d9a85d4ccb.zip
Fix some warnings
Instances of `RegexError` are just asserted as `assert_not_reached` as they cannot really fail except for allocation failure if the given regex is valid.
Diffstat (limited to 'libdino/src/service')
-rw-r--r--libdino/src/service/database.vala74
1 files changed, 42 insertions, 32 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index 5a92446d..604fcdcc 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -236,40 +236,50 @@ public class Database : Qlite.Database {
message.fts_rebuild();
}
if (oldVersion < 8) {
- exec("""
- insert into content_item (conversation_id, time, local_time, content_type, foreign_id, hide)
- select conversation.id, message.time, message.local_time, 1, message.id, 0
- from message join conversation on
- message.account_id=conversation.account_id and
- message.counterpart_id=conversation.jid_id and
- message.type=conversation.type+1 and
- (message.counterpart_resource=conversation.resource or message.type != 3)
- where
- message.body not in (select info from file_transfer where info not null) and
- message.id not in (select info from file_transfer where info not null)
- union
- select conversation.id, message.time, message.local_time, 2, file_transfer.id, 0
- from file_transfer
- join message on
- file_transfer.info=message.id
- join conversation on
- file_transfer.account_id=conversation.account_id and
- file_transfer.counterpart_id=conversation.jid_id and
- message.type=conversation.type+1 and
- (message.counterpart_resource=conversation.resource or message.type != 3)""");
+ try {
+ exec("""
+ insert into content_item (conversation_id, time, local_time, content_type, foreign_id, hide)
+ select conversation.id, message.time, message.local_time, 1, message.id, 0
+ from message join conversation on
+ message.account_id=conversation.account_id and
+ message.counterpart_id=conversation.jid_id and
+ message.type=conversation.type+1 and
+ (message.counterpart_resource=conversation.resource or message.type != 3)
+ where
+ message.body not in (select info from file_transfer where info not null) and
+ message.id not in (select info from file_transfer where info not null)
+ union
+ select conversation.id, message.time, message.local_time, 2, file_transfer.id, 0
+ from file_transfer
+ join message on
+ file_transfer.info=message.id
+ join conversation on
+ file_transfer.account_id=conversation.account_id and
+ file_transfer.counterpart_id=conversation.jid_id and
+ message.type=conversation.type+1 and
+ (message.counterpart_resource=conversation.resource or message.type != 3)""");
+ } catch (Error e) {
+ stderr.printf("Failed to upgrade to database version 8: %s\n", e.message);
+ Process.exit(-1);
+ }
}
if (oldVersion < 9) {
- exec("""
- insert into content_item (conversation_id, time, local_time, content_type, foreign_id, hide)
- select conversation.id, message.time, message.local_time, 1, message.id, 1
- from message join conversation on
- message.account_id=conversation.account_id and
- message.counterpart_id=conversation.jid_id and
- message.type=conversation.type+1 and
- (message.counterpart_resource=conversation.resource or message.type != 3)
- where
- message.body in (select info from file_transfer where info not null) or
- message.id in (select info from file_transfer where info not null)""");
+ try {
+ exec("""
+ insert into content_item (conversation_id, time, local_time, content_type, foreign_id, hide)
+ select conversation.id, message.time, message.local_time, 1, message.id, 1
+ from message join conversation on
+ message.account_id=conversation.account_id and
+ message.counterpart_id=conversation.jid_id and
+ message.type=conversation.type+1 and
+ (message.counterpart_resource=conversation.resource or message.type != 3)
+ where
+ message.body in (select info from file_transfer where info not null) or
+ message.id in (select info from file_transfer where info not null)""");
+ } catch (Error e) {
+ stderr.printf("Failed to upgrade to database version 8: %s\n", e.message);
+ Process.exit(-1);
+ }
}
}