From 5005fddf6908c1e303341f3715a52a636c7df270 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 9 Jul 2014 18:27:21 +0000 Subject: [PATCH] turn updating info into task --- pandora/archive/tasks.py | 11 +++++++++++ pandora/archive/views.py | 12 +++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index 1a91c348..91e42d75 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -80,6 +80,17 @@ def update_files(user, volume, files): i = Item.objects.get(itemId=i) i.update_selected() +@task(ignore_results=True, queue='default') +def update_info(user, info): + files = models.File.objects.filter(oshash__in=info.keys()) + for f in files: + if not f.info: + f.update_info(data['info'][f.oshash], user) + f.save() + for i in Item.objects.filter(files__in=files).distinct(): + i.update_selected() + i.update_wanted() + @task(queue="encoding") def process_stream(fileId): ''' diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 6756a225..3434e817 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -81,15 +81,9 @@ def update(request): user_profile.files_updated = datetime.now() user_profile.save() - if 'info' in data: - files = models.File.objects.filter(oshash__in=data['info'].keys()) - for f in files: - if not f.info: - f.update_info(data['info'][f.oshash], user) - f.save() - for i in Item.objects.filter(files__in=files).distinct(): - i.update_selected() - i.update_wanted() + if 'info' in data and data['info']: + t = tasks.update_info.delay(user.username, data['info']) + response['data']['taskId'] = t.task_id if not upload_only: all_files = models.Instance.objects.filter(volume__user=user) files = all_files.filter(file__available=False)