check for cancel before overwriting activity

This commit is contained in:
j 2016-01-28 17:18:01 +05:30
parent a384a3aad5
commit 8a92429587

View file

@ -214,6 +214,11 @@ def run_import(options=None):
os.unlink(f_import) os.unlink(f_import)
if listname: if listname:
listitems.append(file.item.id) listitems.append(file.item.id)
if state.activity.get('cancel'):
state.activity = {}
return
if not state.tasks.connected:
return
if time.time() - last > 5: if time.time() - last > 5:
last = time.time() last = time.time()
state.activity = { state.activity = {
@ -224,11 +229,6 @@ def run_import(options=None):
} }
trigger_event('activity', state.activity) trigger_event('activity', state.activity)
if state.activity.get('cancel'):
state.activity = {}
return
if not state.tasks.connected:
return
with db.session(): with db.session():
if listname and listitems: if listname and listitems:
l = List.get(settings.USER_ID, listname) l = List.get(settings.USER_ID, listname)