This is provisional documentation describing the planned File Sync implementation.
Architecture
File Sync builds on Spacedrive’s core infrastructure. Each sync operation runs as a Job, providing state persistence and progress tracking. The system derives all sync decisions from the VDFS index, eliminating complex state management and ensuring files ignored during indexing remain excluded from sync.Index-Based Design
The VDFS index serves as the single source of truth for File Sync. When you configure a sync relationship between two locations, the system:- Queries the index for entries at both locations
- Calculates differences based on content hashes and timestamps
- Dispatches existing file operations (copy, delete) to reconcile state
- Updates sync history for conflict detection
Core Principles
Index as TruthIf a file isn’t indexed, it doesn’t exist for sync purposes. This ensures consistency between what you see in Spacedrive and what gets synchronized. Push-Based Transfer The device that has files pushes them to devices that need them. This works naturally with iOS background processing and simplifies the protocol. Library Sync First File Sync requires a complete, up-to-date index via Library Sync before operating. This ensures all devices have the same view of what exists where. Leverage Existing Jobs File Sync orchestrates
FileCopyJob and DeleteJob rather than implementing custom transfer logic. The existing job system already handles local vs remote routing, progress tracking, and error recovery.
Sync Modes
File Sync offers four distinct modes, each designed for specific workflows. Configure these per-location through the sync settings panel.Mirror Mode
Creates an exact copy of your source at the destination. Changes flow one direction only. Perfect for backup scenarios where you want a read-only copy of important data. When you delete a file from the source, Mirror Mode removes it from the destination too. This keeps your backup lean and matches your working set exactly.Bidirectional Mode
Keeps two locations identical across different devices. Changes made anywhere propagate everywhere. Ideal for working on the same projects from multiple computers. The system uses last-write-wins for conflicts. When the same file changes in multiple places, the most recent modification takes precedence. Previous versions remain in your Spacedrive history.Archive Mode
Moves completed work to long-term storage. After verifying successful transfer, the source files are removed to free local space. The system performs cryptographic verification before any deletion. Use this mode when finishing projects. Your files move to cheaper storage while maintaining full Spacedrive search and preview capabilities.Selective Mode
Intelligently manages limited local storage. Frequently accessed files stay local while older content moves to secondary storage. Files remain visible in Spacedrive and download on-demand when needed. The algorithm considers access patterns, available space, and manual pins. You control which files always stay local by pinning them in the Spacedrive interface.Implementation
File Sync uses index queries to determine what needs synchronization. This eliminates filesystem scanning and complex state tracking.Prerequisites
Before File Sync can operate, Library Sync must complete:Sync Resolution
The sync resolver calculates operations by comparing index entries:Index Consistency
Files excluded from indexing (like
node_modules) are automatically excluded from sync. This matches user expectations - if you told Spacedrive to ignore it, it won’t sync either.Network Protocol
File transfers use Spacedrive’s existing P2P infrastructure over QUIC. The protocol supports:- Resumable transfers for large files
- Concurrent block transmission
- Compression for slow links
- Encryption for all data
Transfer Coordination
File Sync uses a push-based model where the device with files initiates transfers:Receiver Validation
When receiving files, devices validate against their local index:Data Model
File Sync introduces theSyncConduit entity to manage sync relationships between directories:
Relationships
SyncConduit creates a directed relationship between two Entry records. The source and target must be directories (kind=1). For bidirectional sync, the direction indicates the initial sync priority but changes flow both ways.Sync History
Track sync operations for conflict detection and debugging:Configuration
Create sync relationships through the Spacedrive interface by right-clicking any directory and selecting “Sync to…”. The system creates a SyncConduit record linking your source and destination.Essential Settings
Sync Schedule: Controls when File Sync runs. Instant mode monitors filesystem events for immediate sync. Periodic modes batch changes for efficiency. Bandwidth Limits: Prevents sync from saturating your connection. Applies per-conduit, so multiple syncs share available bandwidth intelligently. Conflict Resolution: Determines automatic resolution strategy. The system maintains conflict history for manual review regardless of settings.Monitoring
The sync status panel shows all active sync relationships. Monitor transfer progress, view sync history, and troubleshoot issues from a unified interface. Key metrics displayed:- Current transfer speed and ETA
- Queue depth and pending files
- Recent conflicts and resolutions
- Storage space on each device
Limitations
File Sync currently has these constraints:- Maximum file size: 1TB per file
- Excluded files: System files, temporary files
- Platform differences: Some attributes don’t sync across OS types
- Network requirements: Both devices must be online simultaneously
Benefits of Index-Based Sync
The index-driven architecture provides several advantages over traditional filesystem scanning approaches: PerformanceNo directory traversal needed. Sync resolution becomes efficient database queries instead of recursive filesystem operations. Consistency
Files ignored by indexing rules automatically stay out of sync. No divergence between what Spacedrive shows and what gets synchronized. Simplicity
Push-based transfers eliminate complex negotiation protocols. The device with data initiates transfers, making the system predictable and debuggable. Reliability
Library Sync ensures all devices share the same worldview before File Sync operates. Combined with receiver validation, this prevents inconsistent states.
Future Enhancements
Delta Transfers
While the current system transfers whole files, future versions will add block-level delta transfers for large file modifications:Remote Delete Support
The currentDeleteJob lacks cross-device support. Future updates will add remote deletion capability to complete the sync feature set.
Conflict Resolution
Advanced conflict handling will maintain version history and offer multiple resolution strategies beyond last-write-wins.Usage Scenarios
File Sync excels at personal file management workflows: Project Folders: Keep active projects synchronized between laptop and desktop Photo Libraries: Mirror photos from phone to NAS for backup Document Archive: Move completed work to cloud storage automaticallySelective Cache: Keep recent files local while older content lives in cloud The index-based design ensures these workflows remain fast and reliable while respecting your organization preferences.
