clear cover/preview cache on delete

This commit is contained in:
j 2016-01-16 16:27:52 +05:30
parent 1d6e94d1a6
commit 59894b0df7

View file

@ -255,6 +255,8 @@ class Item(db.Model):
Transfer.query.filter_by(item_id=self.id).delete()
Scrape.query.filter_by(item_id=self.id).delete()
state.db.session.delete(self)
icons.clear('cover:%s' % self.id)
icons.clear('preview:%s' % self.id)
if commit:
state.db.session.commit()
@ -330,7 +332,7 @@ class Item(db.Model):
self.info['coverRatio'] = self.info['previewRatio']
elif 'coverRatio' in self.info:
del self.info['coverRatio']
icons.clear('cover:%s:'%self.id)
icons.clear('cover:%s:' % self.id)
def update_preview(self):
key = 'preview:%s'%self.id
@ -349,7 +351,7 @@ class Item(db.Model):
self.info['previewRatio'] = self.info['coverRatio']
elif 'previewRatio' in self.info:
del self.info['previewRatio']
icons.clear('preview:%s:'%self.id)
icons.clear('preview:%s:' % self.id)
def update_icons(self):
self.update_cover()