Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

A JSON state file ended in zeros after an unclean shutdown: quarantine it, then salvage every record you can

Описание и применение

Файл registry.json, используемый Relaymote, повреждён из‑за непредвиденного завершения работы, но система сохраняет его, а команда salvage восстанавливает все корректные задачи, обновляя идентификаторы и зависимости.

Задача

A registry.json file used by Relaymote was corrupted by an unclean shutdown, ending with NUL bytes that caused JSON.parse to fail.

Результат

The daemon now survives corrupted registry files by quarantining them and can recover all valid tasks via a salvage command, preserving ID continuity and dependencies.

Рабочий процесс

  • 1. On load, attempt to parse registry.json.
  • 2. If parsing fails, rename the file to registry.json.corrupt-<timestamp> and log a message with a recovery command.
  • 3. Scan the raw text for task IDs and seq to set the next ID counter above any existing IDs.
  • 4. Start the daemon with an empty registry but a safe ID counter.
  • 5. Run relaymote salvage to attempt recovery: trim padding, close after last complete record, or scan for individual records.
  • 6. Merge recovered tasks into the live registry, renumbering conflicts, updating dependencies, and tagging restored tasks.
  • 7. By default perform a dry run; with --apply write the merged registry using temp‑file, fsync, rename.
  • 8. The corrupted file remains untouched for repeat attempts.

Доказательства

The writes were already done the textbook way: write a temp file, fsync it, rename it over the real one.

Источник

If parsing fails, rename the file to registry.json.corrupt-<timestamp> and log a message with a recovery command.

Источник

The file is written with JSON.stringify(state, null, 2), so every task object ends with a newline and exactly four spaces before its }.

Источник

  • Дата записи: 2026-11-01T11:58:51.190Z