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