From 68919fae241ef3f8e293f601ed167311140a218d Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 24 Mar 2021 20:04:34 -0700 Subject: [PATCH] Fix UI showing outdated cached info when items get refreshed. --- ycdl/ycdldb.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ycdl/ycdldb.py b/ycdl/ycdldb.py index e6d0250..0857225 100644 --- a/ycdl/ycdldb.py +++ b/ycdl/ycdldb.py @@ -130,7 +130,8 @@ class YCDLDBChannelMixin: } self.sql_insert(table='channels', data=data) - channel = self.get_cached_instance('channel', data) + channel = objects.Channel(self, data) + self.caches['channel'][channel_id] = channel if get_videos: channel.refresh(commit=False) @@ -456,7 +457,10 @@ class YCDLDBVideoMixin: self.log.loud('Inserting Video %s.', video.id) self.sql_insert(table='videos', data=data) - video = self.get_cached_instance('video', data) + # Override the cached copy with the new copy so that the cache contains + # updated information (view counts etc.). + video = objects.Video(self, data) + self.caches['video'][video.id] = video if commit: self.commit()