Skip to content

fix: download the file, not the page, for HF blob and Civitai page links - #16

Merged
mogurt merged 3 commits into
mainfrom
fix/page-links-to-files
Sep 30, 2026
Merged

mogurt merged 3 commits into
mainfrom
fix/page-links-to-files

Conversation

@mogurt

@mogurt mogurt commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

Pasting a Hugging Face /blob/ link (the URL of the file viewer page) downloaded a ~130 KB HTML page saved under the model's file name, instead of the model. Example:

https://huggingface.co/Comfy-Org/Qwen-Image-2.1/blob/main/text_encoders/qwen3.5_9b_qwen_image_2.1_pe_i2i.int8_convrot.safetensors

URL Response
…/blob/main/… text/html, 127,700 bytes
…/resolve/main/… application/octet-stream, 9,471,072,252 bytes

Civitai model page links (civitai.com/models/7808/…) had the same problem.

  • ParseResult gains download_url, and the download form now hands that to aria2 instead of the pasted URL.
  • Hugging Face: /blob/ and /raw/ (the latter serves the LFS pointer) are rewritten to /resolve/. Repo pages that point to no file are rejected with a hint.
  • Civitai: model page links map to /api/download/models/{version}, using ?modelVersionId or, if it's missing, the model's latest version.
  • Other links: if HEAD reports text/html, parsing fails with "this link opens a web page" instead of downloading it.
  • Also syncs Cargo.lock's package version to 0.1.2; release-please doesn't update the lock file.

Testing

  • cargo clippy --all-targets -- -D warnings, cargo test: 25 passed, with new tests for the blob/raw → resolve rewrite and Civitai model-id extraction
  • npm run lint, npm run typecheck, npm test: 20 passed

End-to-end in tauri dev (separate data dir), via real IPC and the UI:

  • The link above → …/resolve/main/…, 9,471,072,252 bytes, type clip.
  • Civitai model page, with and without ?modelVersionId=9208 → https://civitai.com/api/download/models/9208, easynegative.safetensors, 24,655 bytes.
  • HF repo page and a GitHub page → clear "page, not a file" errors.
  • Real download through the form from a /blob/ link (hf-internal-testing/tiny-random-bert): aria2 received the /resolve/ URL, and the saved file is 520,212 bytes and starts with the safetensors header, not HTML.

mogurt and others added 3 commits September 30, 2026 11:07
A Hugging Face `/blob/` link (what the file viewer shows) returns the HTML
page, so aria2 saved a ~130 KB web page named like the model. The same
happened for Civitai model page links.

- ParseResult gains `download_url`, which the download form now hands to
  aria2 instead of the pasted URL.
- Hugging Face: rewrite `/blob/` and `/raw/` (LFS pointer) to `/resolve/`;
  repo pages without a file are rejected with a hint.
- Civitai: model page links map to /api/download/models/{version}, using
  ?modelVersionId or else the model's latest version.
- Other links: if HEAD reports text/html, report that the link is a web
  page instead of downloading it.
@mogurt
mogurt merged commit 19554db into main Sep 30, 2026
5 checks passed
@mogurt
mogurt deleted the fix/page-links-to-files branch September 30, 2026 03:56
mogurt pushed a commit that referenced this pull request Sep 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.3](v0.1.2...v0.1.3)
(2026-09-30)


### Bug Fixes

* download the file, not the page, for HF blob and Civitai page links
([#16](#16))
([19554db](19554db))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant