turn updating info into task

This commit is contained in:
j 2014-07-09 18:27:21 +00:00
parent b49dceb63f
commit 5005fddf69
2 changed files with 14 additions and 9 deletions

View file

@ -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):
'''

View file

@ -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)