mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
dump_pointers and dump_passwords: Add error handling for deleted users.
(imported from commit 556c29133a4734014d4640d875c6d6fccc118668)
This commit is contained in:
@@ -17,13 +17,20 @@ def dump():
|
||||
|
||||
def restore(change):
|
||||
for (email, timestamp) in simplejson.loads(file("dumped-pointers").read()):
|
||||
u = UserProfile.objects.get(user__email__iexact=email)
|
||||
try:
|
||||
u = UserProfile.objects.get(user__email__iexact=email)
|
||||
except UserProfile.DoesNotExist:
|
||||
print "Skipping...", email
|
||||
continue
|
||||
if timestamp == -1:
|
||||
pointer = -1
|
||||
else:
|
||||
pointer = Message.objects.filter(
|
||||
pub_date__gte=timestamp_to_datetime(timestamp)).order_by("id")[0].id
|
||||
print "%s: pointer %s => %s" % (email, u.pointer, pointer)
|
||||
try:
|
||||
pointer = Message.objects.filter(
|
||||
pub_date__gte=timestamp_to_datetime(timestamp - 1)).order_by("id")[0].id
|
||||
except IndexError:
|
||||
print "Alert...", email, timestamp
|
||||
continue
|
||||
if change:
|
||||
u.pointer = pointer
|
||||
u.save()
|
||||
|
||||
Reference in New Issue
Block a user