cloud_sync_core 0.1.1
cloud_sync_core: ^0.1.1 copied to clipboard
Storage-agnostic core for the cloud_sync family. Defines StorageAdapter, SyncEngine, SyncClient, ManifestDiffer, and conflict resolution — shared by every backend adapter.
cloud_sync_core #
Storage-agnostic core for the cloud_sync family. This package defines what syncing means — not where it syncs to. Concrete backends (Google Drive, S3, Box, ...) live in sibling packages and implement the StorageAdapter interface.
What's in here #
StorageAdapter— abstract 5-method interface every backend implementsSyncEngine— orchestrates manifest diff → conflict resolution → file transferSyncClient— high-level API (sync,push,pull,status)ManifestDiffer— diffs twoSyncManifestsConflictResolver— applies aConflictStrategyto decide winnersPathValidator— structural path safety (no traversal, no absolute paths)
What's not in here #
- No HTTP code
- No OAuth / auth logic
- No file I/O (callbacks are supplied by the caller or by
SyncClientusingdart:io) - No provider-specific knowledge (Drive, S3, Box)
Implementing a new backend #
class MyAdapter implements StorageAdapter {
@override Future<void> ensureFolder() async { /* create root */ }
@override Future<Map<String, RemoteFileInfo>> listFiles() async { /* list */ }
@override Future<void> uploadFile(String path, List<int> content) async { /* put */ }
@override Future<List<int>> downloadFile(String path) async { /* get */ }
@override Future<void> deleteFile(String path) async { /* delete */ }
}
Then wire it up:
final client = SyncClient(adapter: MyAdapter(...));
final result = await client.sync(localPath: '/path/to/data');
Using an existing backend #
See cloud_sync_drive (Google Drive), cloud_sync_s3 (AWS S3 + compatibles), cloud_sync_box (Box).
License #
MIT