feat(opds): ask before overwriting a book already on SD - #56
Merged
Merged
Conversation
Before downloading, open the destination read-only; if a book is already there, show a Cancel/Confirm dialog (Cancel focused) with its size and FAT modification date, formatted by hand without strftime. No SD writes unless the user confirms. The download path is computed once and passed through. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XgLRarbAmBVepTPKCK7mgd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: downloading a book from the OPDS browser silently replaced a copy already on the SD card.
After: when the book is already there, the browser asks "Book already on SD card. Overwrite?" and shows the existing file's size and modification date (for example "2.3 MB, 2026-09-27 09:08"). Cancel is selected by default. Confirm downloads and replaces the file through the existing
.partstaging, so a failed download still keeps the old copy.How:
requestDownloadopens the destination read-only. That one lookup gives existence, size and the FAT modification time, and nothing is written to SD unless the user confirms. The size is formatted with integer math. The FAT date is decoded by hand (no strftime) and validated withDaylightSaving::isValidDate. The prompt reusesConfirmationActivity. The download path is computed once and passed todownloadBook.Size:
default(C3) +1,224 B flash, x4-pro-light-sleep +1,184 B flash; static RAM (.data/.bss) is unchanged on both.Test: download a book, then select it again. The prompt should appear. Cancel keeps the old file, and Confirm replaces it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XgLRarbAmBVepTPKCK7mgd
Generated by Claude Code