# Simple WebDAV Sync A lightweight Obsidian WebDAV sync plugin with ETag + SHA-256 three-way comparison. Zero npm dependencies, bilingual (EN/ZH). [中文文档](#中文文档) ## Features - **ETag + SHA-256 three-way comparison** — never relies on timestamps, immune to server-side time drift - **Two-way sync** — uploads local changes, downloads remote changes, handles new and deleted files - **Conflict safety** — keeps both versions when both sides change: `{name} (server YYYY-MM-DD).{ext}` - **Safe delete** — local delete triggers server restore; remote delete moves to local `.sync_trash/` - **Real-time sync** — monitors modify / delete / rename events with configurable debounce - **Auto sync** — configurable interval for periodic full sync - **Sync on close** — triggers a full sync when Obsidian closes - **Crash-safe** — persists sync state after each operation - **Bilingual** — English / 中文, auto-detects system language - **Trash management** — view trash size and clear from settings ## Installation ### From Obsidian Community Plugins (recommended) Search for "Simple WebDAV Sync" in Settings → Community Plugins → Browse. ### Manual 1. Download `main.js`, `styles.css`, `manifest.json` from the [latest release](https://github.com/gghyoo/simple-webdav/releases/latest) 2. Copy to your vault's `.obsidian/plugins/simple-webdav/` directory 3. Enable the plugin in Settings → Community Plugins ## Settings | Setting | Description | |---|---| | Server URL | Full WebDAV path to your vault folder (not root) | | Username / Password | WebDAV credentials | | Auto Sync Interval | 0 = disabled | | Debounce Delay (sec) | Wait time after file change before syncing, default 10s | | Language | System default / 中文 / English | | Show Notifications | Toggle sync notification popups | ## Sync Strategy ### Core Principle - **ETag** as the sole remote change indicator - **SHA-256** as the final local change confirmation (after mtime + size quick filter) - Three-way comparison: Local vs Sync Record vs Remote ### Three-Way Decision Matrix | Local vs Record | Remote vs Record | Action | |---|---|---| | Unchanged | Unchanged | Skip | | Changed | Unchanged | Upload | | Unchanged | Changed | Download | | Both changed | Both changed | Conflict, keep both | | Local new | Remote doesn't exist | Upload | | Local doesn't exist | Remote new | Download | ### Delete Policy | Scenario | Action | |---|---| | Local deleted, remote unchanged | Download from server to restore | | Remote deleted, local unchanged | Move local file to `.sync_trash/` | | Both deleted | Clean sync record | ### Ignore Rules ``` ._* # macOS resource forks .DS_Store # macOS directory metadata .sync_state.json # Sync database .sync_trash # Local trash *.tmp # Temporary files ~$* # Office temporary files ``` ## Technical Details - Pure `obsidian.requestUrl` for WebDAV communication, no external dependencies - HTTP/1.1 (HTTP/2 Basic Auth has known compatibility issues) - Sync state stored in vault root as `.sync_state.json` - Desktop only (uses Node.js `crypto` for SHA-256) ## License MIT --- # 中文文档 一个轻量级的 Obsidian WebDAV 同步插件,基于 ETag + SHA-256 三方比较,零依赖,中英双语。 ## 特性 - **ETag + SHA-256 三方比较**:不依赖时钟,彻底解决服务器乱改时间戳导致的误同步问题 - **双向同步**:上传本地修改、下载远程修改,支持新增和删除 - **冲突保留双份**:双方同时修改时,服务器版本保存为 `{name} (服务器 YYYY-MM-DD).{ext}` - **安全删除**:本地删除不删服务器(自动恢复),远程删除移入本地 `.sync_trash/` - **实时同步**:监听 modify / delete / rename 事件,防抖延迟可配置 - **自动同步**:可配置定时全量同步间隔 - **关闭时同步**:Obsidian 关闭时自动触发一次完整同步 - **断电安全**:每个操作完成后立即持久化同步状态 - **中英双语**:自动跟随系统语言,可手动切换 - **回收站管理**:在设置中查看回收站大小并清空