From ddb70beedd6131683c8aa2c4fe7eb31d5d0f7053 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 24 Nov 2023 13:13:56 +0000 Subject: [PATCH] invalidate cache if file changed --- render_kdenlive.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/render_kdenlive.py b/render_kdenlive.py index 92a5f15..82948f5 100644 --- a/render_kdenlive.py +++ b/render_kdenlive.py @@ -13,10 +13,15 @@ def get_propery(element, name): def melt_xml(file): - if file in _CACHE: - out = _CACHE[file] - else: - out = _CACHE[file] = subprocess.check_output(['melt', file, '-consumer', 'xml']).decode() + out = None + real_path = os.path.realpath(path) + if file in _CACHE and isinstance(_CACHE[file], list) + 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