Skip to content

firmware download: reuse a file already in the cache unless --force - #212

Merged
bdbarnett merged 1 commit into
mainfrom
firmware-download-cache
Nov 5, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
firmware-download-cache

Conversation

@bdbarnett

Copy link
Copy Markdown
Collaborator

mpftp firmware download now reuses a firmware file already in ~/.mpftp/firmware-cache/files/ without going online, and says so: already downloaded: PATH (--force fetches it again), with "cached": true in the result. --force refreshes the catalog and downloads the file again. Before, every call opened the download, printed downloading ... and download 100%, and only skipped the write when the server's Content-Length matched the cached size.

A file's name carries its build date and version (ESP32_GENERIC_S3-20260824-v1.29.0.bin), and a download is written as .partial and renamed only when it finishes, so a file of that name is the same build and complete. The web flasher's download goes through the same function and gets the same reuse.

Against micropython.org, two firmware download --board ESP32_GENERIC_S3 --version 1.29.0 calls each took 0.5 s and named the cached file; --force fetched all 1,783,296 bytes again. New tests in cli/tests/test_firmware_download.py cover reuse with no Content-Length, --force, and a cut-off .partial not being reused; they fail without the change.

Closes #210

A second `firmware download` of the same build went back to micropython.org,
printed "downloading" and "download 100%", and only skipped the write when the
server sent a Content-Length matching the cached file. A firmware file's name
carries its build date and version, and a download only takes that name once
it has finished, so a file of that name in the cache is now reused without
going online. The result says "cached": true, and --force downloads it again.

Checked against micropython.org: two downloads of ESP32_GENERIC_S3 1.29.0 took
0.5 s each and named the cached file; --force fetched all 1,783,296 bytes.

Closes #210
@bdbarnett
bdbarnett merged commit 47a71b3 into main Nov 5, 2026
9 checks passed
@bdbarnett
bdbarnett deleted the firmware-download-cache branch November 5, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

firmware download fetches the file again when it's already cached

1 participant