cleanup in progress apply_changes on peer removal
This commit is contained in:
parent
ec50a04097
commit
8e3d8b5f8e
3 changed files with 19 additions and 8 deletions
|
@ -82,6 +82,10 @@ class Changelog(db.Model):
|
|||
def apply_changes(cls, user, changes):
|
||||
trigger = changes
|
||||
for change in changes:
|
||||
if user.id in state.removepeer:
|
||||
user.cleanup()
|
||||
del state.removepeer[user.id]
|
||||
return False
|
||||
if not cls.apply_change(user, change, trigger=False):
|
||||
logger.debug('FAIL %s', change)
|
||||
trigger = False
|
||||
|
|
|
@ -12,6 +12,7 @@ update = False
|
|||
websockets = []
|
||||
|
||||
activity = {}
|
||||
removepeer = {}
|
||||
|
||||
def user():
|
||||
import settings
|
||||
|
|
|
@ -113,12 +113,24 @@ class User(db.Model):
|
|||
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
||||
self.peered = True
|
||||
self.save()
|
||||
if self.id in state.removepeer:
|
||||
del state.removepeer[self.id]
|
||||
else:
|
||||
self.pending = ''
|
||||
self.peered = False
|
||||
self.queued = False
|
||||
self.update_name()
|
||||
self.save()
|
||||
if self.name in settings.ui['showFolder']:
|
||||
del settings.ui['showFolder'][self.name]
|
||||
settings.ui._save()
|
||||
self.cleanup()
|
||||
if was_peering:
|
||||
Changelog.record(state.user(), 'removepeer', self.id)
|
||||
state.removepeer[self.id] = True
|
||||
self.save()
|
||||
|
||||
def cleanup(self):
|
||||
List.query.filter_by(user_id=self.id).delete()
|
||||
for i in self.items:
|
||||
i.users.remove(self)
|
||||
|
@ -126,12 +138,6 @@ class User(db.Model):
|
|||
i.delete()
|
||||
Changelog.query.filter_by(user_id=self.id).delete()
|
||||
Metadata.query.filter_by(user_id=self.id).delete()
|
||||
if self.name in settings.ui['showFolder']:
|
||||
del settings.ui['showFolder'][self.name]
|
||||
settings.ui._save()
|
||||
self.save()
|
||||
if was_peering:
|
||||
Changelog.record(state.user(), 'removepeer', self.id)
|
||||
self.save()
|
||||
|
||||
def update_name(self):
|
||||
|
|
Loading…
Reference in a new issue