mirror of
https://github.com/derrod/legendary.git
synced 2025-01-08 13:55:28 +00:00
[lfs] Fix get_cached_version() reading from disk every time
This commit is contained in:
parent
5fe35c7008
commit
b33396915e
|
@ -297,12 +297,16 @@ class LGDLFS:
|
||||||
return sum(f.stat().st_size for f in Path(self.path).glob('**/*') if f.is_file())
|
return sum(f.stat().st_size for f in Path(self.path).glob('**/*') if f.is_file())
|
||||||
|
|
||||||
def get_cached_version(self):
|
def get_cached_version(self):
|
||||||
|
if self._update_info:
|
||||||
|
return self._update_info
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._update_info = json.load(open(os.path.join(self.path, 'version.json')))
|
self._update_info = json.load(open(os.path.join(self.path, 'version.json')))
|
||||||
return self._update_info
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.debug(f'Failed to load cached update data: {e!r}')
|
self.log.debug(f'Failed to load cached update data: {e!r}')
|
||||||
return dict(last_update=0, data=None)
|
self._update_info = dict(last_update=0, data=None)
|
||||||
|
|
||||||
|
return self._update_info
|
||||||
|
|
||||||
def set_cached_version(self, version_data):
|
def set_cached_version(self, version_data):
|
||||||
if not version_data:
|
if not version_data:
|
||||||
|
|
Loading…
Reference in a new issue