You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6cee0f6
Browse filesBrowse the repository at this point in the historyBrowse files
fix(icons): cache one source per icon, retry rate limits, stop panicking (#390)
Three faults, one cause each.
**One download per colour and per size.** The disk entry was named
`{slug}-{color}-{w}x{h}.svg` because the Iconify URL baked colour and size into
the SVG. A cache could hold 21 copies of `lucide:sparkles`, and changing only a
colour sent an icon that rendered fine offline back to the network. The source
is now fetched once per `prefix:name`, cached under `{slug}.svg`, and recoloured
and resized locally — Lucide draws with `stroke="currentColor"`, so recolouring
is a substitution, and resizing rewrites the root `width`/`height` while leaving
the `viewBox` alone. Done without a regex crate: the attribute rewrite is a
short scan of the root tag.
**No retry.** A single `GET`, so a `429` from `api.iconify.design` under
parallel renders lost the icon. Four attempts with exponential backoff, and only
for `429` and `5xx` — a `404` is not going to resolve on the fourth try, and
retrying it would make a typo take four times as long to report.
**`render` panicked where `still` and `sheet` warned.** The panic was not an
oversight: `an_unresolvable_icon_must_fail_the_preload_not_be_swallowed` exists
to enforce it, and says "must panic (or otherwise hard-fail)". So the severity
stays and the mechanism changes. `prefetch_icons` returns a named
`IconsUnresolved` error, the encode paths propagate it, and `still` and `sheet`
now preload too, so all three fail the same way with the same message and a
clean exit code instead of a backtrace. The studio warns and keeps its preview
alive, which is the one caller that must not die. `validate` stays offline.
$ rustmotion still -f missing-icon.json --time 0 -o out.png
Error: 1 icon(s) could not be loaded — checked the disk cache at
~/.cache/rustmotion/icons and the network, both failed:
- 'lucide:no-such-icon-xyz' (color #2A2F6B, target 84x84px):
Failed to fetch icon: http status: 404
[exit 1]
`disk_cache_is_keyed_by_icon_color_and_size` asserted the first fault as a
guarantee — "different colors must not share a cache file". It is replaced by
its opposite rather than worked around.
Closes#365
0 commit comments