Skip to content

fix: preserve subscription geodata settings in Clash config - #1339

Open
xiaowuap wants to merge 1 commit into
juewuy:devfrom
xiaowuap:codex/preserve-subscription-geodata
Open

xiaowuap wants to merge 1 commit into
juewuy:devfrom
xiaowuap:codex/preserve-subscription-geodata

Conversation

@xiaowuap

Copy link
Copy Markdown

Subscriptions can include GEOSITE/GEOIP rules together with geodata-mode and custom geox-url sources. The current merger keeps the rules but discards those settings, so Mihomo can use the wrong database format or source and fail to start (for example, list google not found in GeoSite.dat).

Preserve geodata-mode, geodata-loader, geosite-matcher, geo-auto-update, geo-update-interval, and the complete geox-url block when generating the runtime YAML. Same-name settings in user.yaml or others.yaml take precedence over subscription values without introducing duplicate subscription keys. If custom configuration validation fails, the base fallback retains the original subscription geodata settings. Temporary fragments are removed during finalization.

This does not replace existing cached databases: an installation with an incompatible cached dataset still needs to refresh that dataset once. It prevents configuration generation from discarding the subscription settings again.

Validation:

  • Added sh tests/clash_geodata.sh; fails on the unmodified dev branch and passes with this change.
  • Covers block/folded and inline URLs, scalar settings, local overrides, base fallback, absent settings, unrelated-key exclusion, and temporary-file cleanup.
  • Passed on Git Bash, Linux /bin/sh, and BusyBox sh; shell syntax and git diff --check passed.
  • Validated generated YAML containing GEOSITE,GOOGLE,DIRECT and GEOIP,GOOGLE,DIRECT with Mihomo v1.19.11 and full geodata: configuration test successful.

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