Fetches only a small portion of the message for previews: Closes #4254, Closes #3799

Before we were fetching the entire message body (including attachments) to get the
preview text.  This patch now offers the ability to fetch a small (128 byte) preview
of the email.

Also, since this ticket is about speeding up performance, I've introduced NonblockingBatch,
which allows for multiple async operations to be executed in parallel easily.  I've added
its use in a few places to speed up operations, including one that was causing the lag
in #3799, which is why this commit closes that ticket.
This commit is contained in:
Jim Nelson 2011-11-16 18:14:17 -08:00
parent 782e6fa5f5
commit 18716ae6ce
22 changed files with 672 additions and 118 deletions

View file

@ -29,7 +29,9 @@ public class Geary.Sqlite.MessageTable : Geary.Sqlite.Table {
HEADER,
BODY;
BODY,
PREVIEW;
}
internal MessageTable(Geary.Sqlite.Database gdb, SQLHeavy.Table table) {
@ -44,8 +46,8 @@ public class Geary.Sqlite.MessageTable : Geary.Sqlite.Table {
SQLHeavy.Query query = locked.prepare(
"INSERT INTO MessageTable "
+ "(fields, date_field, date_time_t, from_field, sender, reply_to, to_field, cc, bcc, "
+ "message_id, in_reply_to, reference_ids, subject, header, body) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ "message_id, in_reply_to, reference_ids, subject, header, body, preview) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
query.bind_int(0, row.fields);
query.bind_string(1, row.date);
query.bind_int64(2, row.date_time_t);
@ -61,6 +63,7 @@ public class Geary.Sqlite.MessageTable : Geary.Sqlite.Table {
query.bind_string(12, row.subject);
query.bind_string(13, row.header);
query.bind_string(14, row.body);
query.bind_string(15, row.preview);
int64 id = yield query.execute_insert_async(cancellable);
locked.set_commit_required();
@ -156,6 +159,15 @@ public class Geary.Sqlite.MessageTable : Geary.Sqlite.Table {
yield query.execute_async(cancellable);
}
if (row.fields.is_any_set(Geary.Email.Field.PREVIEW)) {
query = locked.prepare(
"UPDATE MessageTable SET preview=? WHERE id=?");
query.bind_string(0, row.preview);
query.bind_int64(1, row.id);
yield query.execute_async(cancellable);
}
// only commit if internally atomic
if (transaction == null)
yield locked.commit_async(cancellable);
@ -263,13 +275,15 @@ public class Geary.Sqlite.MessageTable : Geary.Sqlite.Table {
case Geary.Email.Field.BODY:
append = "body";
break;
case Geary.Email.Field.PREVIEW:
append = "preview";
break;
}
}
if (append != null) {
if (!String.is_empty(builder.str))
builder.append(", ");
builder.append(", ");
builder.append(append);
}
}