Skip to content

fix: harden scans, rules, Civitai parsing, open_directory, aria2 lifetime - #13

Merged
mogurt merged 1 commit into
mainfrom
fix/batch3-backend
Sep 28, 2026
Merged

mogurt merged 1 commit into
mainfrom
fix/batch3-backend

Conversation

@mogurt

@mogurt mogurt commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

Batch 3 of the review items: backend robustness.

  • Directory scans
    • scan_workflow_dir and check_models_local now run on a blocking thread instead of the async runtime.
    • Both use one walker that still follows symlinks and junctions, which are common for ComfyUI model folders. It visits each canonical directory once and caps the depth, so link cycles no longer recurse until the stack overflows.
  • open_directory only accepts directories. A file path would have been opened or executed by explorer / open.
  • Custom rules (suggest_type)
    • Malformed rules JSON is now an error.
    • A single rule that doesn't parse, or that names an unknown model type, is skipped with a warning. Before, unwrap_or_default silently discarded every rule.
  • Civitai
    • The model-version metadata status is checked before parsing; a 401/404 JSON body used to be treated as metadata.
    • Content-Disposition parsing prefers filename*, is case-insensitive, and no longer percent-decodes plain quoted names.
  • aria2 lifetime: aria2 is started with --stop-with-process=<app pid>, so it exits by itself when the app crashes or is killed. kill_on_drop never runs in that case, and the orphaned process kept file locks.

Testing

  • cargo fmt --check
  • cargo test: 23 passed on Windows, plus a Unix-only symlink-cycle test that CI's macOS job runs. New tests cover the directory walker, rule parsing and Content-Disposition variants.

End-to-end on Windows (tauri dev with a separate identifier and data dir):

  • Junction cycles (mklink /J back to an ancestor, in both the workflows and the models tree):
    • scan_workflow_dir returns wf.json in 4 ms.
    • check_models_local finds the nested model and reports the missing one, in 3 ms.
  • open_directory with a file path is rejected with "Not a directory".
  • suggest_type
    • A higher-priority rule with type bogus is skipped (warning logged) and the valid rule still applies (lora).
    • {broken JSON is rejected with an explicit error.
  • Civitai URL parse (/api/download/models/9208) still returns the filename, type, size and hash.
  • aria2 lifetime: after force-killing the app process, aria2c (started with --stop-with-process=<pid>) exited on its own within ~2 s.

…time

- Workflow and model scans run on a blocking thread instead of the async
  runtime, and use one walker that still follows symlinks/junctions (common
  for ComfyUI model folders) but visits each canonical directory once and
  caps the depth, so link cycles no longer recurse until the stack overflows.
- open_directory only accepts directories; a file path would have been
  opened/executed by explorer/open.
- suggest_type: malformed rules JSON is an error, and single rules that don't
  parse or name an unknown model type are skipped with a warning, instead of
  unwrap_or_default silently discarding every rule.
- Civitai: check the model-version metadata status before parsing (a 401/404
  JSON body was treated as metadata). Content-Disposition parsing prefers
  filename*, is case-insensitive, and no longer percent-decodes plain names.
- Start aria2 with --stop-with-process=<app pid> so it exits by itself when
  the app crashes or is killed (kill_on_drop never runs in that case).
@mogurt
mogurt merged commit 2c643e0 into main Sep 28, 2026
5 checks passed
@mogurt
mogurt deleted the fix/batch3-backend branch September 28, 2026 15:49
mogurt pushed a commit that referenced this pull request Sep 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.2](v0.1.1...v0.1.2)
(2026-09-29)


### Bug Fixes

* clear-all, editable filenames, duplicate rename, dead settings,
workflow drop
([#10](#10))
([ae5f0fc](ae5f0fc))
* harden scans, rules, Civitai parsing, open_directory, aria2 lifetime
([#13](#13))
([2c643e0](2c643e0))
* path joins with trailing separators, missing translations; add tests
([#14](#14))
([af4b7ce](af4b7ce))
* search errors, sorting, Civitai paging, HF sizes; keep task progress
([#12](#12))
([3321d81](3321d81))

---
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