How sadabx/gdsync works
Purpose and runtime
gdsync is a Linux Rust daemon/CLI for Git-ignore-aware, two-way synchronization between local directories and Google Drive. It uses inotify for near-real-time changes, SQLite for durable sync state, and Google Drive v3 REST APIs for transfers. The Cargo workspace is rooted at Cargo.toml; core logic is a library in crates/gdsync-core/src/lib.rs.
Entry points and user surfaces
The executable entry point is crates/gdsync-cli/src/main.rs, exposing direct commands such as auth, init, sync, watch, and service management. Running without a command enters the interactive terminal UI implemented in crates/gdsync-cli/src/interactive.rs. The CLI orchestrates the core library rather than owning sync behavior.
Configuration, identity, and persistent state
Configuration manages tracked local-to-remote mappings and user credentials, while authentication performs OAuth2 PKCE and persists tokens under the user configuration directory. SQLite stores path records, Drive file IDs, and checksums to compare observed local/remote state across runs.
• crates/gdsync-core/src/config/mod.rs
• crates/gdsync-core/src/auth/mod.rs
• crates/gdsync-core/src/db/mod.rs
Google Drive boundary
The Drive layer is the external-service adapter: it authenticates API calls using cached OAuth tokens and performs folder/file lookup, uploads, downloads, metadata comparison, and recoverable remote trashing. It owns Google Drive v3 REST interaction, including resumable/chunked transfers and retry/backoff behavior.
• crates/gdsync-core/src/drive/mod.rs
• crates/gdsync-core/src/auth/mod.rs
Ignore-aware local discovery
The filter stage evaluates .gitignore and .gdsyncignore, including nested rules, so scans and watcher events exclude generated or explicitly ignored content before it reaches planning or transfer logic. This boundary prevents unwanted files from entering synchronization.
• crates/gdsync-core/src/filter/mod.rs
• crates/gdsync-core/src/sync/mod.rs
Reconciliation and safety policy
The sync engine performs initial and explicit two-way reconciliation: it compares local files, remote Drive state, and persisted SQLite records; plans uploads/downloads/deletions; detects concurrent offline edits; preserves local conflicts; and applies deletion-safety thresholds unless forced. It also supports dry-run planning and bounded concurrent transfer execution.
• crates/gdsync-core/src/sync/mod.rs
• crates/gdsync-core/src/db/mod.rs
• crates/gdsync-core/src/drive/mod.rs
Daemon event flow and deployment
The watcher converts kernel inotify events into debounced sync work, reusing ignore filtering and sync policy rather than directly mutating Drive. It is intended to run persistently, including as a systemd user service managed through the CLI. Release automation is defined in .github/workflows/release.yml; Linux installation is packaged through install.sh.
• crates/gdsync-core/src/watcher/mod.rs
• crates/gdsync-cli/src/main.rs
• .github/workflows/release.yml
Components 14
User surface
- CLI commands · Provides auth, init, sync, watch, and service commands.
crates/gdsync-cli/src/main.rs - Interactive terminal UI · Default surface when no command is supplied.
crates/gdsync-cli/src/interactive.rs
Core library
- Core API · Shared orchestration library for CLI and daemon flows.
crates/gdsync-core/src/lib.rs - Sync engine · Plans and executes safe two-way reconciliation.
crates/gdsync-core/src/sync/mod.rs - Ignore filter · Applies nested .gitignore and .gdsyncignore rules.
crates/gdsync-core/src/filter/mod.rs - Inotify watcher · Debounces filesystem events into sync work.
crates/gdsync-core/src/watcher/mod.rs
State and identity
- Tracked mappings config · Stores local-to-remote mappings and user settings.
crates/gdsync-core/src/config/mod.rs - OAuth token manager · Runs OAuth2 PKCE and caches credentials.
crates/gdsync-core/src/auth/mod.rs - Sync state · Persists paths, Drive IDs, and checksums.
crates/gdsync-core/src/db/mod.rs
External integration
- Google Drive adapter · Handles Drive v3 metadata and resumable transfers.
crates/gdsync-core/src/drive/mod.rs - Google Drive v3
- systemd user service · Runs persistent watcher-based synchronization.
Delivery
- Release workflow
.github/workflows/release.yml - Linux installer
install.sh
Connections 16
- CLI commands → Interactive terminal UI: opens by default
- CLI commands → Core API: orchestrates
- Interactive terminal UI → Core API: uses
- Core API → Sync engine: exposes
- Core API → Inotify watcher: runs
- Core API → Tracked mappings config: loads mappings
- Sync engine → Ignore filter: filters local discovery
- Sync engine → Sync state: compares persisted state
- Sync engine → Google Drive adapter: plans transfers
- Inotify watcher → Ignore filter: filters events
- Inotify watcher → Sync engine: queues debounced work
- Google Drive adapter → OAuth token manager: uses cached tokens
- Google Drive adapter → Google Drive v3: Drive v3 REST
- CLI commands → systemd user service: manages service
- systemd user service → Inotify watcher: runs persistently
- Release workflow → Linux installer: publishes installation