This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Cloudreve Desktop is a Tauri-based Windows desktop application that synchronizes files with a Cloudreve cloud drive server using the Windows Cloud Files API (cfapi). It provides:
- Real-time bidirectional file synchronization
- On-demand file hydration (files appear locally but are downloaded only when accessed)
- Windows Explorer shell integration (context menus, thumbnails, custom states)
- Multiple storage provider support for uploads (S3, OneDrive, Qiniu, Upyun, local)
- System tray application with React-based UI
# Backend (Rust) - run from project root
cargo build # Build all workspace crates
cargo build --release # Release build
cargo check # Check for compilation errors
cargo test # Run all tests
cargo test --package cloudreve-sync --lib inventory::db::tests # Run specific module tests
cargo test --package cloudreve-api # Run API crate tests
# Frontend (React/TypeScript) - run from ui/ directory
cd ui
yarn install # Install dependencies
yarn dev # Start Vite dev server (localhost:5173)
yarn build # Build for production
yarn lint # Run ESLint
# Full Tauri Application - run from project root
cargo tauri dev # Development mode with hot reload
cargo tauri build # Production build├── src-tauri/ # Tauri application shell
├── crates/
│ ├── cloudreve-sync/ # Core sync service (main logic)
│ ├── cloudreve-api/ # Async REST client for Cloudreve server
│ └── win32_notif/ # Windows notification utilities
└── ui/ # React frontend (Vite + MUI)
lib.rs: Application entry, initializes sync service, sets up system tray, spawns event bridgecommands.rs: Tauri IPC commands exposed to frontend (list_drives,add_drive,remove_drive, etc.)event_handler.rs: BridgesEventBroadcasterevents to Tauri frontend events
Initialization Flow: App starts → system tray setup → async init_sync_service() spawned → DriveManager created → shell services initialized → event bridge connects EventBroadcaster to Tauri
Drive Management:
drive/manager.rs: CentralDriveManagercoordinating all mounted drives via command channeldrive/mounts.rs: Individual mount point (Mount) handlingdrive/callback.rs: Windows Cloud Filter callbacks (SyncFiltertrait)drive/sync.rs: Sync logic and placeholder/metadata conversiondrive/remote_events.rs: SSE handling for server-pushed changes
Windows Cloud Files API (cfapi/):
filter/: Callback traits (SyncFilter,Filter) and request handlingplaceholder.rs,placeholder_file.rs: Cloud file placeholder managementroot/: Sync root registration and connection
Persistence (inventory/):
- SQLite via Diesel ORM at
~/.cloudreve/meta.db - Stores file metadata, task queue, upload sessions, drive properties
- Migrations in
migrations/inventory/
Uploads (uploader/):
- Chunked upload with provider backends: S3, OneDrive, Qiniu, Upyun, local
- Encryption and resumable upload support
Shell Extensions (shellext/):
- Context menus, thumbnails, custom file states, status UI
shell_service.rs: COM-based Windows Explorer integration
React 19 + TypeScript + MUI + Vite application:
src/pages/popup/: Main tray popup (drive list, task progress)src/pages/AddDrive.tsx: Add drive wizardsrc/pages/settings/: Settings pages- i18n via react-i18next, translations in
ui/public/locales/
Command Channels: DriveManager and Mount use mpsc::UnboundedSender for async command dispatch from shell extensions and Tauri commands.
Callback Threading: Windows Cloud Filter callbacks run on OS threads, using blocking_recv() on oneshot channels to await async operations.
Event Broadcasting: EventBroadcaster (tokio broadcast channel) pushes events to both the Tauri frontend (via event bridge) and any SSE subscribers.
Global State: APP_STATE (tokio OnceCell) holds initialized DriveManager, EventBroadcaster, and service handles for the application lifetime.
- Requires Windows Cloud Files API (
windowscrate with extensive feature flags in Cargo.toml) - COM shell extensions for Explorer integration
- Deep link protocol:
cloudreve:// - Single instance enforcement via
tauri-plugin-single-instance
Migrations are embedded and run automatically on startup. To add a new migration:
- Create folder in
migrations/inventory/(e.g.,0005_new_table/) - Add
up.sqlanddown.sqlfiles - Use idempotent SQL (
IF NOT EXISTS) for clean upgrades
- Backend:
rust-i18nmacro with translations inlocales/ - Frontend:
react-i18nextwith translations inui/public/locales/{locale}/common.json