App: user files must survive a failed read (usage.json, tags.json, studio.json, wrong-typed sections, locked files)

Chiusa
#71 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
json, python

Direzione di ricerca

Start with the load() paths in zorbit/usage.py, zorbit/tags.py, and zorbit/config.py, then review zorbit/studio.py, zorbit/fsutil.py, and zorbit/paths.py alongside the audit IDs. Run the existing tests for these modules and add focused coverage for failed, malformed, and locked-file cases. Done means valid state is preserved or defaults are reported when reads fail, unsafe asset names are rejected, failed writes are retried, and configuration errors produce a readable application message.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

From the audit of ZOrbit 0.11.0 (31 October 2026).

What is wrong

  • zorbit/usage.py load() sets self.mtime and empties brushes, menus and picks before it opens the file. If the read fails (a scanner or sync client holding the file, or a hand-edit typo) the except clause passes, the object believes it has loaded that mtime, and the next pick saves the empty state over the file. One bad entry inside the brushes loop also drops every later brush, all auto-slot state and the whole Recent list, because they are read after it in one try block.
  • zorbit/tags.py load() keeps "the previous state" when the file cannot be parsed. On the first load of a process there is no previous state, so a stray comma in tags.json leaves no tags at all, Favourites included. Every tag and browser slot is then reported as "tag X does not exist", which points the user away from the real cause.
  • zorbit/config.py: bridge = raw.get("bridge") or {} and ring = raw.get("ring") or {} assume dicts. "bridge": "F9" or "ring": "big" raises AttributeError, the whole file is dropped, the app logs 'str' object has no attribute 'items' and Studio shows one problem with no location. A menu's fan is not validated, so "fan": "false" is true. Misspelt names inside ring.colors, bridge, browser and item fields are ignored without the "did you mean" that the 0.11.0 ring and menu keys got.
  • zorbit/config.py: brush, alpha, material and texture names and icon values are not checked as names. assets._resolve, brushes.thumbnail and radiald.icon_for call is_file() on them, so a menus file with \\host\share\a.png makes Windows connect to that server and send an NTLM hash (while Studio previews the ring, or on the first pick). The COPYDATA path in radiald.py already rejects such names.
  • zorbit/studio.py _read_studio_file returns {} for a missing and for an unreadable file. set_pref (on every screen change), add_zbrush_folder and the window-placement writer then write that empty dict back, dropping the other keys.
  • zorbit/fsutil.py write_atomic: os.replace fails at once with PermissionError when another process holds the destination open (antivirus, OneDrive, the app reading the file it watches). Studio shows "radial.json could not be written: Access is denied".
  • zorbit/paths.py ensure_config runs outside the fatal handler in radiald.main; an unwritable %APPDATA% ends the app with a traceback in app_stderr.log and nothing else.

Fix

  • usage.load: build the new state in locals and assign on success; on OSError keep the previous state and mtime so the next load retries; on a parse error copy the file to usage.json.bad before any save; per-entry try.
  • tags.load: on a parse error with empty _tags, install the starter tags in memory and keep .error so writes stay refused; config.py and the problems list say "tags.json could not be read" when tags.error is set.
  • config.load: isinstance(dict) checks for the top level, bridge, ring, browser and menus with a plain problem text and defaults; fan must be a bool; suggestions for the other key levels; reject names and icons containing \, /, : or .. or starting with \\ or //, listed as problems.
  • studio.py: distinguish missing from unreadable and skip the write when the read failed.
  • write_atomic: retry os.replace four or five times with a short pause on PermissionError or winerror 5 and 32.
  • ensure_config inside the fatal handler, with a readable message.

Audit ids: F122, F042, F047, F048, F231, F232, F028, F032, F013, F307, F373, F371, F372, F123, F366.

Lingua principale
Python
Stelle
2
Fork
1
Merge medio
3m
PR unite (30g)
2

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di combwizard/ZOrbit

Tutte le issue di combwizard/ZOrbit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.