invalidate cache if file changed
This commit is contained in:
parent
5295d1bfc9
commit
ddb70beedd
1 changed files with 9 additions and 4 deletions
|
@ -13,10 +13,15 @@ def get_propery(element, name):
|
||||||
|
|
||||||
|
|
||||||
def melt_xml(file):
|
def melt_xml(file):
|
||||||
if file in _CACHE:
|
out = None
|
||||||
out = _CACHE[file]
|
real_path = os.path.realpath(path)
|
||||||
else:
|
if file in _CACHE and isinstance(_CACHE[file], list)
|
||||||
out = _CACHE[file] = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode()
|
ts, out = _CACHE[file]
|
||||||
|
if os.stat(real_path).st_mtime != ts:
|
||||||
|
out = None
|
||||||
|
if not out:
|
||||||
|
out = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode()
|
||||||
|
_CACHE[file] = [os.stat(real_path).st_mtime, out]
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue