Avoid database error when adding attachments

do_save_attachments() is called by schema update 22, which is prior
to when DeleteAttachmentFileTable was introduced (in update 24).
Ignore error if cannot remove from that table, i.e. it doesn't exist
yet.
This commit is contained in:
Jim Nelson 2015-01-13 13:51:28 -08:00
parent 260436e92c
commit ee7efd3a93

View file

@ -1990,13 +1990,19 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
attachment_id, filename);
// On the off-chance this is marked for deletion, unmark it
stmt = cx.prepare("""
DELETE FROM DeleteAttachmentFileTable
WHERE filename = ?
""");
stmt.bind_string(0, saved_file.get_path());
stmt.exec(cancellable);
try {
stmt = cx.prepare("""
DELETE FROM DeleteAttachmentFileTable
WHERE filename = ?
""");
stmt.bind_string(0, saved_file.get_path());
stmt.exec(cancellable);
} catch (Error err) {
debug("Unable to delete from DeleteAttachmentFileTable: %s", err.message);
// not a deal-breaker, fall through
}
debug("Saving attachment to %s", saved_file.get_path());