Skip to content

feat: add WebDAV cloud sync (pull from Clash Verge backups) - #790

Open
muzi-xiaoren wants to merge 5 commits into
MetaCubeX:mainfrom
muzi-xiaoren:feat/webdav-sync
Open

muzi-xiaoren wants to merge 5 commits into
MetaCubeX:mainfrom
muzi-xiaoren:feat/webdav-sync

Conversation

@muzi-xiaoren

@muzi-xiaoren muzi-xiaoren commented Jun 29, 2026 •

Copy link
Copy Markdown

Context

Clash Verge (desktop) can back up its profiles to a WebDAV server, but there is no way to get those subscriptions onto the phone short of re-adding each one by hand. This PR lets CMFA pull them from the same WebDAV backup.

Feature

A new Settings → WebDAV Sync screen:

  • Server URL / username / password — the same values as in Clash Verge. The password is masked in the list.
  • Test connection — checks the address and credentials and reports how many Clash Verge backups were found.
  • Pull and sync now — downloads the newest backup (by timestamp, across desktops on different OSes) and applies it like a restore in Clash Verge:
    • Subscriptions (type: remote) are updated in place when they already exist (matched by Verge uid, then URL, then name), so their uuid and proxy selections survive; new ones are created.
    • Every other local profile is deleted, and the profile selected on the desktop becomes active.
    • Verge's local and enhancement profiles have no equivalent here and are skipped (the count is shown).
  • A log dialog shows progress per subscription. The sync can be cancelled: it stops after the current subscription, deletes nothing and switches nothing. Failed subscriptions can be retried from the same dialog.
  • Safety: an empty backup changes nothing; a subscription that fails to fetch keeps its last good config; a sync never leaves the phone without an active profile.

The sync is pull-only: nothing is ever written to the WebDAV server.

Strings are provided in English, zh, zh-TW, zh-HK, ja, ko, ru and vi.

New dependencies: OkHttp 4.12.0 (PROPFIND is not supported by HttpURLConnection) and SnakeYAML 2.2 (to read profiles.yaml), with matching ProGuard rules.

Evidence

  • The feature through test connection, cancel and retry has been built by CI and released in my fork as v2.11.36-webdav; I use it on my phone against a Jianguoyun WebDAV backup, and the sync dialog shows the per-subscription log as expected.
  • Not verified: the two most recent commits (newest backup across OSes, per-subscription failure isolation, password mask, active-profile fallback, extra translations) have not been built or run on a device yet.
  • Not verified: WebDAV servers other than Jianguoyun. The ja / ko / ru / vi translations were not reviewed by native speakers.
  • There are no automated tests for this feature.

Merge Danger

  • Destructive by design: a sync deletes every local profile that is not in the backup, including local file profiles. This mirrors Clash Verge's restore and is spelled out on the settings screen, but it is easy to lose a phone-only profile.
  • The WebDAV password is stored in plain text in the app's shared preferences, which are part of Android's backup.
  • Adds two dependencies to the app module (APK size).
  • The backup directory name and file-name format are tied to clash-verge-rev; if it changes them, the sync will stop finding backups.

🤖 Generated with Claude Code

Add a "WebDAV Sync" settings screen that connects to the same WebDAV server
Clash Verge backs up to, downloads the latest backup zip and applies its
subscription profiles, like a restore in Clash Verge.

- WebDavClient: PROPFIND list + GET download (OkHttp, Basic auth) against the
  fixed `clash-verge-rev-backup/` directory Clash Verge uses.
- VergeBackup: unzip + parse profiles.yaml (SnakeYAML); remote (subscription)
  profiles are applied, local/enhancement profiles are skipped.
- Sync mirrors Verge's restore, which replaces the whole profile list: the local
  list ends up holding exactly the backup's subscriptions and the profile Verge
  had selected becomes active. Existing subscriptions (matched by Verge uid, then
  URL, then name) are updated in place so their uuid and proxy selections
  survive; other local profiles are deleted. An empty backup is ignored.
- A dialog shows progress and a per-subscription log while syncing.
- Credentials stored in UiStore, EN/zh strings, SnakeYAML R8 keep rules.

Pull-only (no upload), so it never changes desktop state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
muzi-xiaoren and others added 4 commits October 9, 2026 16:07
…bscriptions

- "Test connection" lists the backup directory and reports the backup count
  and latest file, or an auth or network error.
- The sync dialog's cancel button stops after the current subscription; a
  cancelled sync skips deleting and switching profiles.
- When subscriptions fail, the dialog offers "Retry failed (N)", which
  re-applies only those subscriptions in the same dialog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lures

- Order backups by timestamp instead of by file name, so a Windows backup no
  longer always wins over a newer macOS/Linux one.
- A failing patch/create now fails only that subscription instead of aborting
  the whole sync before the mapping is saved.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- The settings list shows a mask instead of the WebDAV password.
- A sync no longer leaves the phone without an active profile: it falls back to
  another synced subscription, or keeps the active profile if none synced.
- Translate the WebDAV strings for zh-TW, zh-HK, ja, ko, ru and vi.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.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