Match worker fingerprint for stale detection
This commit is contained in:
parent
47c15124d9
commit
cf6830e803
1 changed files with 20 additions and 9 deletions
29
new.php
29
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue