Commit c1a9d312 authored by Jim Nelson's avatar Jim Nelson

Don't crash when message on remote not in local is removed

Forgot to deal with situation where a message in the remote folder
is removed that isn't stored in the local database.  In that case,
the local position will be <= 0 and should be treated as a NOP
(although still signal that the total remote_count has changed).
parent 851f8f03
......@@ -798,11 +798,18 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
// marked for removal, which that helper function doesn't like
local_position = remote_position - (remote_count - local_count);
debug("do_replay_remove_message: local_count=%d local_position=%d", local_count, local_position);
Imap.UID? uid = yield local_folder.get_uid_at_async(local_position, null);
if (uid != null)
owned_id = new Imap.EmailIdentifier(uid, path);
// zero or negative means the message exists beyond the local vector's range, so
// nothing to do there
if (local_position > 0) {
debug("do_replay_remove_message: local_count=%d local_position=%d", local_count, local_position);
Imap.UID? uid = yield local_folder.get_uid_at_async(local_position, null);
if (uid != null)
owned_id = new Imap.EmailIdentifier(uid, path);
} else {
debug("do_replay_remove_message: message not stored locally (local_count=%d local_position=%d)",
local_count, local_position);
}
} catch (Error err) {
debug("Unable to determine ID of removed message #%d from %s: %s", remote_position,
to_string(), err.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment