dont update timeline in update_selected, remove unused async get_item case

This commit is contained in:
j 2016-06-16 14:48:54 +02:00
parent 0486d62ec9
commit 6dcbcdd19c
2 changed files with 13 additions and 19 deletions

View file

@ -68,7 +68,7 @@ def update_files(user, volume, files):
volume, created = models.Volume.objects.get_or_create(user=user, name=volume) volume, created = models.Volume.objects.get_or_create(user=user, name=volume)
all_files = [f['oshash'] for f in files] all_files = [f['oshash'] for f in files]
#remove deleted files # remove deleted files
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files) removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
ids = [i['public_id'] for i in Item.objects.filter( ids = [i['public_id'] for i in Item.objects.filter(
files__instances__in=removed.filter(file__selected=True)).distinct().values('public_id')] files__instances__in=removed.filter(file__selected=True)).distinct().values('public_id')]
@ -105,9 +105,9 @@ def process_stream(fileId):
file = models.File.objects.get(id=fileId) file = models.File.objects.get(id=fileId)
file.encoding = False file.encoding = False
file.save() file.save()
file.item.update_selected(update_timeline=False) file.item.update_selected()
if not file.item.rendered \ if not file.item.rendered \
and not file.item.files.exclude(id=fileId).filter(Q(queued=True)|Q(encoding=True)).count(): and not file.item.files.exclude(id=fileId).filter(Q(queued=True) | Q(encoding=True)).count():
file.item.update_timeline() file.item.update_timeline()
if file.item.rendered: if file.item.rendered:
file.item.save() file.item.save()

View file

@ -64,7 +64,7 @@ def get_id(info):
return imdbId return imdbId
return None return None
def get_item(info, user=None, async=False): def get_item(info, user=None):
''' '''
info dict with: info dict with:
imdbId, title, director, year, imdbId, title, director, year,
@ -98,11 +98,8 @@ def get_item(info, user=None, async=False):
item.external_data = item_data item.external_data = item_data
item.user = user item.user = user
item.oxdbId = item.public_id item.oxdbId = item.public_id
item.save(sync=not async) item.save(sync=True)
if async: item.update_external()
tasks.update_external.delay(item.public_id)
else:
item.update_external()
else: else:
public_id = get_id(info) public_id = get_id(info)
if public_id: if public_id:
@ -124,9 +121,8 @@ def get_item(info, user=None, async=False):
item = existing_item item = existing_item
except Item.DoesNotExist: except Item.DoesNotExist:
item.oxdbId = item.oxdb_id() item.oxdbId = item.oxdb_id()
p = item.save(sync=not async) item.save(sync=True)
if not p and async: tasks.update_poster.delay(item.public_id)
tasks.update_poster.delay(item.public_id)
else: else:
qs = Item.objects.filter(find__key='title', find__value__iexact=info['title']) qs = Item.objects.filter(find__key='title', find__value__iexact=info['title'])
if 'year' in info: if 'year' in info:
@ -137,9 +133,8 @@ def get_item(info, user=None, async=False):
item = Item() item = Item()
item.data = item_data item.data = item_data
item.user = user item.user = user
p = item.save(sync=not async) item.save(sync=True)
if not p and async: tasks.update_poster.delay(item.public_id)
tasks.update_poster.delay(item.public_id)
return item return item
def get_path(f, x): def get_path(f, x):
@ -361,6 +356,7 @@ class Item(models.Model):
self.public_id = str(uuid.uuid1()) self.public_id = str(uuid.uuid1())
self.add_default_data() self.add_default_data()
super(Item, self).save(*args, **kwargs) super(Item, self).save(*args, **kwargs)
update_poster = True
if not settings.USE_IMDB: if not settings.USE_IMDB:
self.public_id = ox.toAZ(self.id) self.public_id = ox.toAZ(self.id)
@ -462,7 +458,7 @@ class Item(models.Model):
for a in self.annotations.all().order_by('id'): for a in self.annotations.all().order_by('id'):
a.item = other a.item = other
a.set_public_id() a.set_public_id()
Annotations.objects.filter(id=a.id).update(item=other, public_id=a.public_id) Annotation.objects.filter(id=a.id).update(item=other, public_id=a.public_id)
if hasattr(self, 'files'): if hasattr(self, 'files'):
for f in self.files.all(): for f in self.files.all():
@ -1186,7 +1182,7 @@ class Item(models.Model):
qs = qs.exclude(id__in=wanted) qs = qs.exclude(id__in=wanted)
qs.update(wanted=False) qs.update(wanted=False)
def update_selected(self, update_timeline=True): def update_selected(self):
sets = self.sets() sets = self.sets()
for s in sets: for s in sets:
if s.filter(Q(is_video=True) | Q(is_audio=True)).filter(available=False).count() == 0: if s.filter(Q(is_video=True) | Q(is_audio=True)).filter(available=False).count() == 0:
@ -1202,8 +1198,6 @@ class Item(models.Model):
if update: if update:
self.rendered = False self.rendered = False
self.save() self.save()
if update_timeline:
tasks.update_timeline.delay(self.public_id)
break break
if not sets: if not sets:
self.rendered = False self.rendered = False