Skip to content

feat: add persistent image cache and centralize frontend constants#74

Merged
SuperKali merged 1 commit intomainfrom
feature/persistent-image-cache
Jan 10, 2026
Merged

feat: add persistent image cache and centralize frontend constants#74
SuperKali merged 1 commit intomainfrom
feature/persistent-image-cache

Conversation

@SuperKali
Copy link
Copy Markdown
Member

@SuperKali SuperKali commented Jan 9, 2026

Summary

Implements persistent image cache (#72) to prevent re-downloading images when flashing fails. Downloaded images are now stored locally and reused for subsequent flash attempts, significantly improving the user experience when dealing with unreliable SD cards or connection issues.

Also includes frontend codebase improvements: centralization of all hardcoded constants and a bug fix for board image fallback.

Cache Features

  • Enable/disable cache toggle - Users can opt-out if storage is limited
  • Configurable size limit - Dropdown with options: 5, 10, 20 (default), 50, 100 GB
  • LRU eviction - Automatically removes oldest images when cache exceeds limit
  • Cache status display - Shows current cache size with "Clear cache" button
  • Auto-cleanup on failure - Removes cached image after 3 consecutive flash failures (likely corrupted)

Frontend Constants Centralization

Moved all hardcoded values to src/config/constants.ts:

  • EVENTS - Custom DOM events for inter-component communication
  • STORAGE_KEYS - SessionStorage keys for flash failure tracking
  • SETTINGS - Tauri Store keys and default values
  • COLORS - UI colors (icons, alerts, QR codes)
  • UI - Skeleton counts, marquee sizes, icon dimensions
  • VENDOR - Board vendor fallback identifiers

Bug Fixes

  • Fixed board image fallback not displaying when image preload fails (404 errors)
  • Pin zbus to 5.12.0 to avoid breaking changes in 5.13.0

Build Improvements

  • Commit Cargo.lock for reproducible builds

Technical Details

Backend (Rust):

  • New cache.rs module with thread-safe operations (Mutex + once_cell::Lazy)
  • Path traversal protection using canonicalize() before file operations
  • LRU eviction based on file modification time (filetime crate)
  • Input validation with bounds checking (1-100 GB)

Frontend (React):

  • Cache settings UI in Settings → General section
  • Confirmation dialog for destructive "Clear cache" action
  • Flash failure tracking persisted via sessionStorage

Screenshots

image

Closes #72

@SuperKali SuperKali added enhancement New feature or request component: ui User interface related component: settings Settings and preferences component: backend Rust backend related i18n Internationalization and translations labels Jan 9, 2026
@SuperKali SuperKali force-pushed the feature/persistent-image-cache branch from 30f95b2 to 80872ab Compare January 9, 2026 22:05
Implement Issue #72 - persistent image cache that keeps downloaded
images for faster retry when flashing fails.

Cache Features:
- Toggle to enable/disable image caching in Settings
- Configurable maximum cache size (5-100 GB, default 20 GB)
- LRU eviction when cache exceeds size limit
- Clear cache button with confirmation dialog
- Auto-delete cached image after 3 consecutive flash failures

Backend (Rust):
- New cache.rs module with thread-safe operations (Mutex)
- Path traversal protection using canonicalize()
- Cache size validation with configurable bounds
- LRU eviction based on file modification time (filetime crate)

Frontend Constants Centralization:
- EVENTS: Custom DOM events for inter-component communication
- STORAGE_KEYS: SessionStorage keys for flash failure tracking
- SETTINGS: Tauri Store keys and default values
- COLORS: UI colors (icons, alerts, QR codes)
- QR_CODE: QR code generation configuration
- UI: Skeleton counts, marquee sizes, icon dimensions
- VENDOR: Board vendor fallback identifiers

Bug Fixes:
- Fixed board image fallback not displaying when preload fails (404)
- Pin zbus to 5.12.0 to avoid breaking changes in 5.13.0

Build:
- Commit Cargo.lock for reproducible builds

Localization:
- Added cache-related translations to all 18 locales
@SuperKali SuperKali force-pushed the feature/persistent-image-cache branch from 80872ab to 67ece73 Compare January 9, 2026 22:12
@SuperKali SuperKali requested a review from igorpecovnik January 9, 2026 22:14
@SuperKali SuperKali merged commit 28baeb0 into main Jan 10, 2026
@SuperKali SuperKali deleted the feature/persistent-image-cache branch January 10, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: backend Rust backend related component: settings Settings and preferences component: ui User interface related enhancement New feature or request i18n Internationalization and translations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add persistent cache images when is downloaded

1 participant