Skip to content

fix: make list strictly read-only, stop rewriting .index.json - #23

Merged
classx merged 2 commits into
classx:mainfrom
alexeynikandrov:main
Aug 31, 2026
Merged

classx merged 2 commits into
classx:mainfrom
alexeynikandrov:main

Conversation

@alexeynikandrov

Copy link
Copy Markdown
Contributor

Проблема

rfc-cli list при каждом запуске изменял docs/rfcs/.index.json, хотя должен только читать данные.

Причина

list вызывает index::refresh_index, который в конце безусловно выполнял save_index — пере-сериализовывал и перезаписывал .index.json (fs::write) даже когда ни один RFC не менялся. Это меняло mtime и содержимое файла на ровном месте.

Решение

  • Логика сканирования вынесена в приватную refresh_entries, возвращающую флаг dirty.
  • refresh_index теперь сохраняет индекс только при реальных изменениях.
  • Добавлен refresh_index_readonly — обновляет индекс в памяти без записи на диск.
  • list переведён на read-only вариант.

Поведение остальных команд (new, edit, set, link, unlink, deps, check, doctor, status) не изменилось — они по-прежнему актуализируют и сохраняют индекс.

Проверка

  • Двойной запуск list → .index.json побайтно идентичен, mtime не меняется.
  • cargo test: 96 passed (2 падения test_view_* — пред-существующие, не связаны с правкой).
  • cargo fmt --check — чисто.

Прочее

  • Версия поднята до 0.1.5, добавлена запись в CHANGELOG.md.

alexeynikandrov and others added 2 commits August 31, 2026 10:02
The `list` command called `refresh_index`, which unconditionally wrote
`docs/rfcs/.index.json` on every invocation (re-serialize + fs::write),
changing the file's mtime and content even when nothing had changed.

Extract the scanning logic into `refresh_entries`, returning a `dirty`
flag. `refresh_index` now persists only when a real change is detected,
and a new `refresh_index_readonly` performs an in-memory refresh without
touching disk. `list` uses the read-only variant.

Bump version to 0.1.5 and document the fix in CHANGELOG.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@classx
classx merged commit 5bd2cb5 into classx:main Aug 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants