Skip to content

Barcode Gen: fix first-save failure and make save errors descriptive - #236

Merged
mishamyte merged 2 commits into
devfrom
fix/barcode-gen-save-errors
Jul 23, 2026
Merged

Barcode Gen: fix first-save failure and make save errors descriptive#236
mishamyte merged 2 commits into
devfrom
fix/barcode-gen-save-errors

Conversation

@mishamyte

Copy link
Copy Markdown
Collaborator

Fixes #234

Problem

Creating a barcode (e.g. CODE-128) on a fresh install always failed with a generic "A saving error has occurred":

  1. The /ext/apps_data/barcodes folder was only created by init_folder() in free_app() - i.e. on app exit, never at startup - so the very first save had no folder to write into.
  2. save_barcode() collapsed every failure (missing folder, duplicate file name, missing SD card, empty fields) into one generic message, and empty name/data returned silently with no feedback at all.

Changes

Folder creation (issue 1)

  • init_folder() now runs at startup in barcode_main() and returns whether the folder is usable; save_barcode() calls it again before each save as a safety net (covers mid-session SD removal)
  • Real mkdir failures are logged as errors instead of the previous "Barcodes folder already exists" INFO line

Descriptive errors (issue 2)

  • Empty name / empty data / no type now show a message instead of silently returning
  • One mode-independent clobber guard: saving or renaming over any existing file other than the barcode's own shows "A file with this name already exists" (previously New mode failed with the generic error and Edit mode silently destroyed the other barcode)
  • A failed edit-mode rename fails the save with "Could not rename the barcode file" instead of being logged and buried under "File Saved!"; on success the model path is synced so later failures leave no stale path
  • All flipper_format_write_* results are checked - a partially written file (e.g. SD card removed mid-save) is reported instead of "File Saved!"
  • mkdir failure surfaces as "Cannot access the SD card"
  • Save and delete failures return to the create/edit form with the entered data intact instead of dropping to the main menu; the message view got a next_view field (with a safe default) and multiline rendering via elements_multiline_text_aligned
  • New message_view_show() helper replaces three hand-rolled copies of the show-message sequence

Housekeeping

  • CHANGELOG.md added, backfilled for 1.1-1.4 from repo history and upstream releases; fap_version bumped to 1.5
  • Removed the never-defined message_view_free_model() declaration

Testing

  • Builds clean with ufbt (Target 7, API 88.0), ufbt format applied
  • Installed and launched on a physical Flipper Zero
  • Reviewed by code-review, silent-failure, comment-accuracy and simplification passes; all findings addressed or noted

🤖 Generated with Claude Code

mishamyte and others added 2 commits July 23, 2026 19:27
Fixes #234

- Call init_folder() in barcode_main() instead of free_app(), so
  /ext/apps_data/barcodes exists before the first save attempt instead
  of being created only on app exit. Also ensure the folder exists in
  save_barcode() as a safety net.
- Show a message for empty Name/Data/Type instead of silently returning.
- Detect the "file already exists" case in New mode (open_new fails on
  existing files) and report it instead of the generic error.
- Add next_view to the message view so save errors return to the create
  view (keeping the entered data) instead of the main menu.
- Support multiline messages in the message view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review follow-ups on top of the #234 fixes:

- Fail the save with a specific message when an edit-mode rename would
  overwrite another barcode or the rename itself fails; sync the model
  path after a successful rename so a later failure leaves no stale path.
- Check all flipper_format write results; a partially written file is
  no longer reported as "File Saved!".
- Report a mkdir failure as "Cannot access the SD card" and log real
  init_folder failures as errors instead of "already exists".
- Unify the New/Edit duplicate-name checks into one mode-independent
  clobber guard; collapse the three status flags into one error_message
  sentinel; only allocate the FlipperFormat when the save can proceed.
- Move the show-message helper into the message view (message_view_show)
  and reuse it from edit_barcode_item; reuse init_folder in save_barcode.
- Give next_view a safe default, dismiss only on short presses, and
  keep delete/save failures in the edit view so entered data survives.
- Add CHANGELOG.md backfilled from repo and upstream release history;
  bump fap_version to 1.5.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added pack/base App bundled in base_pack category/tools App category: tools labels Jul 23, 2026
@mishamyte mishamyte added the type/bug Something isn't working label Jul 23, 2026
@mishamyte
mishamyte merged commit 2c7b67c into dev Jul 23, 2026
2 checks passed
@mishamyte
mishamyte deleted the fix/barcode-gen-save-errors branch July 23, 2026 16:52
Repository owner locked as resolved and limited conversation to collaborators Jul 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

category/tools App category: tools pack/base App bundled in base_pack type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Barcode Generator: first save fails with generic error (folder created on exit, not on entry)

1 participant