From 89271cd4e8406eb39aa89d9862c7bfcaa127cbbf Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 10 Oct 2026 21:55:07 +0800 Subject: [PATCH] provider, plugin, settings: accounts left all zero by a crash are read from their last good copy, and every state file is flushed before it is renamed in (#1505, Zhangwier) Zhangwier's Windows machine went down hard, and logins.json (10783 bytes) and plugin-auth.json (29926 bytes) came back at full length with every byte 0x00. Every account was gone. The rename had reached the disk before the data. magpie then read "no accounts", and its next write would have made that final. What changed: - Flushed before rename: steady.WriteFile writes a temp file, fsyncs it, then renames it in. A failed write or flush removes the temp file and leaves the old file as it was. edit.WriteAtomic, Kiro's writer, the Codex session rewrite and the plugin host's writeDurable (host.js) flush the same way. So do writePrivate (providers, logins, migrations), settings, profiles, plugins.json, plugin-auth.json and mcp-signins.json. - A last good generation: before each write, lastgood.Keep keeps the valid file there as .bak. A file that isn't valid is copied aside as .bad-