From cf6830e803220594d23ef015e24f984b73c2eada Mon Sep 17 00:00:00 2001 From: hbrain Date: Thu, 28 May 2026 18:00:50 +0200 Subject: [PATCH] Match worker fingerprint for stale detection --- new.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/new.php b/new.php index f86372b..f506e48 100644 --- a/new.php +++ b/new.php @@ -136,15 +136,26 @@ function unique_input_dir($base, $slug){ } } function input_dir_signature($dir){ - $entries = []; - foreach (scandir($dir) ?: [] as $file) { - if ($file === '.' || $file === '..' || in_array($file, ['.movmaker-state.json','.movmaker-enabled','.movmaker-preview','.mvlog-hidden'], true)) continue; - if ($file === '.movmaker-lock') continue; - $path = $dir . '/' . $file; - if (is_file($path)) $entries[] = [$file, filesize($path), filemtime($path)]; - } - sort($entries); - return hash('sha256', json_encode($entries, JSON_UNESCAPED_UNICODE)); + $script = <<<'PY' +import hashlib, json, os, sys +root = sys.argv[1] +entries = [] +for dirpath, dirnames, filenames in os.walk(root): + dirnames[:] = [d for d in dirnames if d != '.movmaker-lock'] + for name in filenames: + if name in {'.movmaker-state.json', '.movmaker-enabled', '.movmaker-preview', '.mvlog-hidden'}: + continue + path = os.path.join(dirpath, name) + rel = os.path.relpath(path, root) + st = os.stat(path) + mtime_ns = getattr(st, 'st_mtime_ns', int(st.st_mtime * 1_000_000_000)) + entries.append([rel, st.st_size, mtime_ns]) +entries.sort() +print(hashlib.sha256(json.dumps(entries, ensure_ascii=False, separators=(',', ':')).encode('utf-8')).hexdigest()) +PY; + $cmd = 'python3 -c ' . escapeshellarg($script) . ' ' . escapeshellarg($dir); + $output = trim(shell_exec($cmd) ?? ''); + return $output !== '' ? $output : ''; } function input_dir_info($dir){ $data = read_data($dir);