locorda_dir 0.5.2
locorda_dir: ^0.5.2 copied to clipboard
Local filesystem backend for Locorda BYOB sync. Primarily for development and testing; also works with mounted network/cloud drives on macOS/Linux.
locorda_dir #
Local filesystem backend for Locorda β primarily for development and testing. Also works with mounted network/cloud drives (NAS, iCloud Drive, etc.) on macOS/Linux for simple multi-device sync; Windows untested.
Overview #
locorda_dir provides a file-based remote storage backend that syncs your Locorda data to a local directory. Primarily designed for development and testing; also works on macOS/Linux with mounted network or cloud drives (NAS, iCloud Drive, Synology, etc.) for simple multi-device sync without a dedicated cloud backend.
Features #
- ποΈ File-Based Storage: Sync data as Turtle (.ttl) files in a local directory
- π» Desktop-Focused: Optimized for platforms with direct file system access
- π Direct Access: View and backup your synced data directly from the file system
- π¦ Type-Based Organization: Files organized in subdirectories by resource type
- β‘ ETag Support: Efficient sync using file modification times
- ποΈ Simple Auth: Toggle sync on/off with a simple boolean switch
Platform Support #
| Platform | Support | Default Path |
|---|---|---|
| macOS | β Full | ~/Documents/<appName>/locorda-sync/ |
| Linux | β Full | ~/Documents/<appName>/locorda-sync/ |
| Windows | β οΈ Untested | %USERPROFILE%\Documents\<appName>\locorda-sync\ |
| iOS | β οΈ Limited | App sandbox (not user-accessible) |
| Android | β οΈ Limited | App sandbox (not user-accessible) |
| Web | β Not supported | N/A |
Usage #
Main Thread Setup #
import 'package:locorda_dir/locorda_dir.dart';
// Create the integration
final dirIntegration = await DirMainIntegration.create(
appName: 'my-app', // Used for directory naming
initiallyEnabled: false, // Sync disabled by default
);
// Use in your RemoteIntegrationRegistry
final registry = RemoteIntegrationRegistry([
dirIntegration,
// ... other backends
]);
Worker Thread Setup #
import 'package:locorda_dir/worker.dart' as worker;
// Register the worker handler
final workerHandlers = [
worker.DirWorkerHandler(appName: 'my-app'),
// ... other worker handlers
];
Directory Structure #
Files are organized by resource type:
~/Documents/my-app/locorda-sync/
βββ Note/
β βββ abc123.ttl
β βββ def456.ttl
βββ Category/
β βββ xyz789.ttl
βββ idx/
βββ note-index.ttl
How It Works #
- Authentication: Simple boolean toggle - sync is either enabled or disabled
- File Format: All data stored as RDF Turtle files
- ETag Generation: Based on file modification time + size for efficient sync
- Conflict Resolution: Uses Locorda's CRDT merge logic (same as cloud backends)
UI Components #
Login Screen #
Shows users:
- How the feature works
- The sync directory path
- Toggle to enable/disable sync
- Button to open directory in Finder/Explorer
// Automatically shown via RemoteIntegration.showLogin()
await dirIntegration.showLogin(context);
Comparison with Cloud Backends #
| Feature | Local Dir | Solid Pod | Google Drive |
|---|---|---|---|
| Offline Access | β Always | β οΈ Cache | β οΈ Cache |
| Multi-Device Sync | β Manual | β Automatic | β Automatic |
| File Access | β Direct | β οΈ Via API | β οΈ Via API |
| Backup | Manual copy | Pod provider | |
| Privacy | β Fully local | β Self-hosted | β οΈ Google |
Use Cases #
- Development & Testing: Quick local storage without cloud setup
- Local Backups: Keep a local copy alongside cloud sync
- Offline-First: True offline operation without network dependency
- File System Integration: Use standard backup tools (Time Machine, rsync, etc.)
- Data Inspection: Easily inspect RDF data in text editor
Limitations #
- No Multi-Device Sync: Files are local to one machine
- Manual Backup Required: No automatic cloud backup
- Desktop Only: Mobile support is limited to app sandbox
- No Collaboration: Single user only
Development #
Run tests:
cd packages/locorda_dir
flutter test
Format code:
dart format .
Analyze:
dart analyze