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 = Item.objects.get(itemId=i)
|
||||||
i.update_selected()
|
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")
|
@task(queue="encoding")
|
||||||
def process_stream(fileId):
|
def process_stream(fileId):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -81,15 +81,9 @@ def update(request):
|
||||||
user_profile.files_updated = datetime.now()
|
user_profile.files_updated = datetime.now()
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
|
|
||||||
if 'info' in data:
|
if 'info' in data and data['info']:
|
||||||
files = models.File.objects.filter(oshash__in=data['info'].keys())
|
t = tasks.update_info.delay(user.username, data['info'])
|
||||||
for f in files:
|
response['data']['taskId'] = t.task_id
|
||||||
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 not upload_only:
|
if not upload_only:
|
||||||
all_files = models.Instance.objects.filter(volume__user=user)
|
all_files = models.Instance.objects.filter(volume__user=user)
|
||||||
files = all_files.filter(file__available=False)
|
files = all_files.filter(file__available=False)
|
||||||
|
|
Loading…
Reference in a new issue