feat(install): 三道防坏防丢门禁 —— 尾部实包解码 / 同卷隔离区两阶段提交 / 无缓冲回读
§10.161 的复盘结论不是「再查一遍」,是三个结构性缺口,逐个补上: ① tail_decode_gate():上传后真解码远端副本的最后几秒。 `+faststart` 把 moov 放在文件头,所以 ffprobe 对截断文件照样报全长 —— 抽检 1,340 件成品里 6 件截断(1.4 GB 只剩 36.9 MB)全都过了既有门禁。 窗口 min(5s, dur/2),短片不假阳性;`-map 0:v:0?` 让无视频流不误红。 ② 隔离区两阶段提交(move_to_trash / restore_from_trash / purge_trash / publish_staged): 安装段不再 `os.replace` 覆盖 + `os.remove(src)` 删原件,而是 目标名上的文件同卷 rename 进 `<dir>/.transcode_trash/<date>/`(0 字节拷贝、可回滚), 发布成功才让它留在那儿;发布或装后任一闸门失败就地回滚。 GC 72 h 后回收,且**旁注里的 live 已消失时绝不删**(那是最后一份)。 ③ _win_unbuffered_read / _sha_sample_nocache / _sha_remote_sample_nocache: 抽样回读走 FILE_FLAG_NO_BUFFERING,Dokan/RaiDrive 的缓存池再也答不上话。 读窗按扇区对齐并按 GetFileSizeEx 裁到最后一个整扇区(无缓冲读不许跨 EOF, 越过末尾是 ERROR_INVALID_PARAMETER 而不是 EOF);末尾 < 4 KB 的零头用普通读补。 短读抛 _ShortRead 并**不许**退回缓存读;只有文件系统拒绝该 flag 才降级, 并把 bypassed=False 写进回执。 隔离区对引擎 collect() 不可见(否则退休的原件会被重新入队)。 门禁默认全开,`--no-tail-gate` 只是紧急刹车,`--trash-ttl-hours` 默认 72。 真共享盘端到端实测:源 213,827 B → hvc1 25,854 B,原件逐字节躺在隔离区,cache_bypass=true。 版本 1.2.0 → 1.3.0(contract 3 不变)。
This commit is contained in:
1 parent
005b824e4f
commit
46c9177386
3 files changed
+476
-64
No files matched your search
@@ -176,12 +176,19 @@ from a small runner instead:
|
||||
2. encode locally, with the same mandatory flags (`-fps_mode cfr`, `-pix_fmt yuv420p`)
|
||||
3. run the structural gate **and** a full decode pass on the local output
|
||||
4. upload to `<name>.new.mp4` (never the final name)
|
||||
5. read the share copy back end-to-end and compare **SHA-256 + byte count** with the local file
|
||||
6. only then `os.replace()` it over the original, and re-probe the result on the share
|
||||
5. read the uploaded copy back with the **Windows cache bypassed** (`FILE_FLAG_NO_BUFFERING`) and
|
||||
compare **SHA-256 + byte count** with the local file, then really **decode its last seconds**
|
||||
(`-sseof -5 -f null -`)
|
||||
6. only then **two-phase-commit** it: move the original into the same-volume quarantine
|
||||
`<dir>/.transcode_trash/<date>/` (an inode rename — never a delete), publish the verified file,
|
||||
and roll the original back if the publish or any post-install gate fails
|
||||
|
||||
Step 5 costs one extra network read (~1 h per 330 GiB) and is the only thing that actually
|
||||
proves the remote copy is complete — `getsize()` cannot, and neither can a duration probe:
|
||||
with `+faststart` the `moov` is written first, so a truncated file still reports full duration.
|
||||
proves the remote copy is complete — `getsize()` cannot, a duration probe cannot (with
|
||||
`+faststart` the `moov` is written first, so a truncated file still reports full duration), and a
|
||||
buffered read cannot either: Dokan/RaiDrive answer sampled windows from the local cache pool while
|
||||
the server holds a fraction of the file. Step 6 is what makes a failed install recoverable: the
|
||||
original is in the quarantine, not gone.
|
||||
Keep a JSONL ledger and a per-file skip test ("already HEVC hvc1") so a reboot resumes safely.
|
||||
A single instance only; the lock matters even more here because two runs would race on `dst`.
|
||||
|
||||
|
||||
Reference in new issue
Block a user