fix: make list strictly read-only, stop rewriting .index.json - #23
Merged
Merged
Conversation
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
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема
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.