diff --git a/pandora/item/models.py b/pandora/item/models.py index 388a7c2ec..362203565 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -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): diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index bbbeed336..2774a4cd0 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -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):