akiomik / akiomik/nostui

A configuration nostui cannot look at is reported as one that is not there

Abierto
#584 3 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Rust
Estrellas
71
Forks
5
Merge medio
4 h 2 min
PR fusionados (30 d)
31

Descripción

Split out of [#576](https://github.com/akiomik/nostui/pull/576), which carried an attempt at this through eight rounds of review and removed it. What follows is what those rounds established, so the next attempt does not rediscover it.

## What happens

`Config::new` decides a configuration is absent with `Path::exists`, which answers `false` for a name it cannot look at as readily as for one that is not there. So:

- a config directory with no execute bit, holding a `config.json`, is reported as empty — and its owner is told to create the directory and write the file, both of which exist;
- a `config.json5` symlinked to itself is skipped in silence, so someone editing it sees no effect and no reason;
- a `config.json` that exists but cannot be *opened* is worse still: `exists` says true, `config::File::…required(false)` swallows the `EACCES`, and the run ends at `missing configuration field "key"` — a field the file may well contain. (Also noted on #578.)

## What #576 tried, and what each attempt hit

Recorded because each one looked right until the next case:

| attempt | broken by |
| --- | --- |
| `try_exists`, report the directory | one failing candidate took the instructions away from someone who had no configuration at all |
| report the failing path instead | with every candidate failing, the path kept was arbitrary — a reader of `config.json` was pointed at `config.json5` |
| report the directory when every candidate failed | five symlink loops in a directory anyone can read blamed the directory |
| ask `read_dir` whether the directory is readable | `read_dir` wants `r`, `try_exists` wants `x`: mode 444 with a configuration in it reports absence, mode 111 with nothing in it reports unreadability |

The shape of the trouble is that "is it absent?" and "whose fault is it?" are different questions, and every rule tried answered the second by inferring it from the first.

## What is worth keeping from it

- The instructions belong in the message whatever happened: a reader has no configuration either way, and needs to know what nostui wants. Replacing them with a diagnosis was the worst of the failures, because it reproduced #113 exactly.
- A name that could not be looked at is worth reporting whether or not a configuration was found — silence is what leaves someone editing a file nostui never reads.
- Whether a directory can be looked in is not answerable by counting which names failed, nor by a probe that asks for a different permission than the lookups do.

## Acceptance

- A configuration behind a directory or file this process cannot read is distinguished from one that is not there, for every combination of `r` and `x` on the directory.
- Whatever is said, a reader with no usable configuration is still told where one goes and what to put in it.
- The distinguishing is asserted for each case, and a test fails when it is wrong — the shapes above are a starting list.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.