update_poster should always update poster

This commit is contained in:
j 2016-08-05 14:45:39 +02:00
parent 2aef460225
commit c4a95bc320
2 changed files with 7 additions and 3 deletions

View file

@ -1392,6 +1392,11 @@ class Item(models.Model):
for f in glob(os.path.join(settings.MEDIA_ROOT, self.path(), 'timeline*.jpg')):
os.unlink(f)
def remove_poster(self):
if self.poster:
self.clear_poster_cache(self.poster.path)
self.poster.delete()
def clear_poster_cache(self, poster):
for f in glob(poster.replace('.jpg', '*.jpg')):
if f != poster:
@ -1442,9 +1447,7 @@ class Item(models.Model):
ox.makedirs(os.path.join(settings.MEDIA_ROOT, self.path()))
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, close_fds=True)
p.communicate(json.dumps(data, default=fields.to_json))
for f in glob(poster.replace('.jpg', '*.jpg')):
if f != poster:
os.unlink(f)
self.clear_poster_cache(poster)
return poster
def poster_frames(self):

View file

@ -54,6 +54,7 @@ def update_clips(public_id):
@task(ignore_results=True, queue='default')
def update_poster(public_id):
item = models.Item.objects.get(public_id=public_id)
item.remove_poster()
item.make_poster()
item.make_icon()
if item.poster and os.path.exists(item.poster.path):