populate_db: Make double-unsubscribes not a fatal error.

(imported from commit 4dadb28f9c310659ddd780e98da70da55ace7187)
This commit is contained in:
Tim Abbott 2012-11-07 11:14:43 -05:00
parent 95c39cbc76
commit 02b7bcf1a4
1 changed files with 7 additions and 2 deletions

View File

@ -464,8 +464,13 @@ def restore_saved_messages():
continue
elif old_message["type"] == "subscription_removed":
stream_key = (realms[old_message["domain"]].id, old_message["name"])
subscribers.setdefault(stream_recipients[stream_key].id,
set()).remove(users[old_message["user"]].id)
user_id = users[old_message["user"]].id
subscribers.setdefault(stream_recipients[stream_key].id, set())
try:
subscribers[stream_recipients[stream_key].id].remove(user_id)
except KeyError:
print "Error unsubscribing %s from %s: not subscribed" % (
old_message["user"], old_message["name"])
pending_subs[(stream_recipients[stream_key].id,
users[old_message["user"]].id)] = False
continue