forked from 0x2620/pandora
turn updating info into task
This commit is contained in:
parent
b49dceb63f
commit
5005fddf69
2 changed files with 14 additions and 9 deletions
|
@ -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):
|
||||
'''
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue