mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-07-30 08:46:04 -04:00
* fix: update tests and examples for upstream API changes Align error types, struct fields, and constructor calls in 27 test/example files to match current Core API: - Box<dyn Error> -> Box<dyn Error + Send + Sync> to match Core::new()/shutdown() - entry::ActiveModel device_id -> volume_id (field rename) - location::ActiveModel add volume_id field (new nullable field) - AppConfig add proxy_pairing and spacebot fields (config v5/v6) - Re-export ProxyPairingConfig from config module - VolumeFingerprint::new() -> from_primary/external/network_volume() - DeviceInfo add device_type field, NetworkFingerprint public_key -> public_key_hash - SecretKey::generate(thread_rng) -> from_bytes (rand_core version mismatch) - SdPath::Physical.path String -> PathBuf, thumbnail_url &Uuid -> &str - init_sync_service unwrap networking Option for Arc<dyn NetworkTransport> * fix: prevent busy-loop in sync loop when real-time sync is active The sync loop's Ready state used 'continue' when is_realtime_active() returned true, which skipped the sleep at the bottom of the loop and caused a CPU-saturating busy-loop logging 'Skipping catch-up' hundreds of thousands of times per second. Replace with if/else so the realtime-active branch falls through to the configurable sleep.
sd-client
Rust client library for connecting to the Spacedrive daemon.
Features
- Unix socket communication with Spacedrive core
- Type-safe query and action execution
- Media file listing queries
- Thumbnail URL construction
- Smart thumbnail variant selection
Usage
use sd_client::{SpacedriveClient, SdPath};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create client
let mut client = SpacedriveClient::new(
"/path/to/daemon.sock".into(),
"http://localhost:54321".into(),
);
// Set library context
client.set_library("library-uuid".to_string());
// Query media files
let files = client.media_listing(
SdPath::Physical {
device_id: "local".to_string(),
path: "/Users/you/Photos".to_string(),
},
Some(1000),
).await?;
// Get thumbnail URLs
for file in files {
if let Some(content_id) = file.content_identity {
if let Some(thumb) = client.select_best_thumbnail(&file.sidecars, 256.0) {
let url = client.thumbnail_url(
&content_id.uuid,
&thumb.variant,
&thumb.format,
);
println!("{}: {}", file.name, url);
}
}
}
Ok(())
}
Example
Run the test connection example:
export SD_LIBRARY_ID="your-library-uuid"
export SD_SOCKET_PATH="$HOME/.spacedrive/daemon.sock" # optional
export SD_HTTP_URL="http://127.0.0.1:54321" # optional
cargo run --example test_connection
API
SpacedriveClient
new(socket_path, http_base_url)- Create a new clientset_library(library_id)- Set the current library contextexecute(wire_method, input)- Execute a query or actionmedia_listing(path, limit)- Query media filesthumbnail_url(content_uuid, variant, format)- Construct thumbnail URLselect_best_thumbnail(sidecars, target_size)- Pick optimal thumbnail variant
Types
File- File metadata with content identity and sidecarsContentIdentity- Content hash and UUID for deduplicationSidecar- Generated derivatives (thumbnails, proxies, etc.)SdPath- Location-independent file referenceImageMediaData- Image-specific metadata (dimensions, date taken)VideoMediaData- Video-specific metadata (dimensions, duration)