Skip to content

Commit c63f1b0

Browse files
authored
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.
1 parent d14413a commit c63f1b0

28 files changed

Lines changed: 260 additions & 157 deletions

core/examples/create_memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use sd_core::domain::memory::{DocumentType, FactType, MemoryFile, MemoryScope};
77
use std::path::PathBuf;
88

99
#[tokio::main]
10-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
10+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1111
// Initialize logging
1212
tracing_subscriber::fmt().with_env_filter("info").init();
1313

core/examples/file_type_demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use sd_core::filetype::FileTypeRegistry;
44

55
#[tokio::main]
6-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
6+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
77
// Create registry with built-in types
88
let registry = FileTypeRegistry::new();
99

core/examples/indexing_demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::path::PathBuf;
2424
use tokio::time::{sleep, Duration};
2525

2626
#[tokio::main]
27-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
27+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
2828
// Initialize logging with more detail
2929
tracing_subscriber::fmt()
3030
.with_env_filter("sd_core=debug,desktop_indexing_demo=info")

core/examples/job_logging_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::PathBuf;
1111
use tokio::time::{sleep, Duration};
1212

1313
#[tokio::main]
14-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
14+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1515
// Initialize logging
1616
tracing_subscriber::fmt()
1717
.with_env_filter("sd_core=debug")

core/examples/library_demo.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::path::PathBuf;
66
use uuid::Uuid;
77

88
#[tokio::main]
9-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
9+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1010
// Initialize logging
1111
tracing_subscriber::fmt()
1212
.with_env_filter("sd_core=debug")
@@ -125,8 +125,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
125125
accessed_at: Set(None),
126126
indexed_at: Set(None),
127127
permissions: Set(None),
128-
device_id: Set(Some(inserted_device.id)),
129128
inode: Set(None),
129+
volume_id: Set(None),
130130
};
131131
let entry_record = entry.insert(db.conn()).await?;
132132

@@ -143,6 +143,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
143143
error_message: Set(None),
144144
total_file_count: Set(0),
145145
total_byte_size: Set(0),
146+
volume_id: Set(None),
146147
job_policies: Set(None),
147148
created_at: Set(chrono::Utc::now()),
148149
updated_at: Set(chrono::Utc::now()),

core/examples/pause_resume_demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tempfile::TempDir;
1414
use tokio::time::sleep;
1515

1616
#[tokio::main]
17-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
17+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1818
// Initialize logging
1919
tracing_subscriber::fmt::init();
2020

core/examples/shutdown_demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::time::Duration;
55
use tokio::time::sleep;
66

77
#[tokio::main]
8-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
8+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
99
// Initialize logging
1010
tracing_subscriber::fmt::init();
1111

core/examples/simple_pause_resume.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::time::Duration;
88
use tokio::time::sleep;
99

1010
#[tokio::main]
11-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
11+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1212
// Initialize logging
1313
tracing_subscriber::fmt::init();
1414

core/examples/test_migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use sea_orm::{ConnectionTrait, Database, Statement};
55
use sea_orm_migration::MigratorTrait;
66

77
#[tokio::main]
8-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
8+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
99
// Initialize logging
1010
tracing_subscriber::fmt()
1111
.with_max_level(tracing::Level::DEBUG)

core/examples/volume_demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::time::Duration;
99
use tokio::time::timeout;
1010

1111
#[tokio::main]
12-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
12+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
1313
// Initialize logging
1414
tracing_subscriber::fmt()
1515
.with_env_filter("sd_core=info")

0 commit comments

Comments
 (0)