Files
S.L c63f1b078b fix: update tests/examples for upstream API changes and fix sync loop busy-loop (#3057)
* 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.
2026-04-18 18:51:13 -07:00

57 lines
1.5 KiB
Rust

//! Simple migration test to verify the schema works
use sd_core::infra::db::migration::Migrator;
use sea_orm::{ConnectionTrait, Database, Statement};
use sea_orm_migration::MigratorTrait;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// Initialize logging
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.init();
println!("=== Migration Test ===\n");
// Create a temporary database for testing
std::fs::create_dir_all("./data")?;
let db_path = "./data/test_migration.db";
if std::path::Path::new(db_path).exists() {
std::fs::remove_file(db_path)?;
}
// Connect to database
let db_url = format!("sqlite://{}?mode=rwc", db_path);
println!("Connecting to database: {}", db_url);
let db = Database::connect(&db_url).await?;
// Run migrations
println!("Running migrations...");
Migrator::up(&db, None).await?;
println!("✓ Migrations completed successfully!");
// List tables to verify
println!("\nCreated tables:");
let result = db
.query_all(Statement::from_string(
sea_orm::DatabaseBackend::Sqlite,
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name",
))
.await?;
let tables: Vec<String> = result
.into_iter()
.filter_map(|row| row.try_get_by::<String, _>("name").ok())
.collect();
for table in tables {
println!(" - {}", table);
}
// Clean up
drop(db);
std::fs::remove_file(db_path)?;
Ok(())
}