diff --git a/Cargo.lock b/Cargo.lock index f27a3d4..d2892f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -744,9 +744,9 @@ dependencies = [ [[package]] name = "cooklang-sync-client" -version = "0.4.8" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2930c61b2b674aab5f7ff3283d9362dd8db6607d48d84046e053b8f9c6819f" +checksum = "ee272c7198268a3354d1b3bde14300df51432652cacf2f2582cca63d0102ff64" dependencies = [ "async-stream", "base64", @@ -754,6 +754,7 @@ dependencies = [ "diesel_migrations", "env_logger", "futures", + "libsqlite3-sys", "log", "notify", "notify-debouncer-mini", @@ -771,26 +772,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -1182,15 +1163,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" -[[package]] -name = "encoding_rs" -version = "0.8.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" -dependencies = [ - "cfg-if", -] - [[package]] name = "enum-map" version = "2.7.3" @@ -1409,21 +1381,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.2" @@ -1627,25 +1584,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "h2" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "hashbrown" version = "0.14.5" @@ -1779,7 +1717,6 @@ dependencies = [ "bytes", "futures-channel", "futures-core", - "h2", "http", "http-body", "httparse", @@ -1808,22 +1745,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.20" @@ -1842,11 +1763,9 @@ dependencies = [ "percent-encoding", "pin-project-lite", "socket2", - "system-configuration", "tokio", "tower-service", "tracing", - "windows-registry", ] [[package]] @@ -2401,23 +2320,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "native-tls" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "new_debug_unreachable" version = "1.0.6" @@ -2538,50 +2440,6 @@ dependencies = [ "pathdiff", ] -[[package]] -name = "openssl" -version = "0.10.76" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" -dependencies = [ - "bitflags 2.11.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" - -[[package]] -name = "openssl-sys" -version = "0.9.112" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -3100,22 +2958,17 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64", "bytes", - "encoding_rs", "futures-channel", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", "hyper", "hyper-rustls", - "hyper-tls", "hyper-util", "js-sys", "log", - "mime", - "native-tls", "percent-encoding", "pin-project-lite", "quinn", @@ -3126,7 +2979,6 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-native-tls", "tokio-rustls", "tokio-util", "tower 0.5.3", @@ -3298,15 +3150,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "scheduled-thread-pool" version = "0.2.7" @@ -3338,29 +3181,6 @@ dependencies = [ "tendril", ] -[[package]] -name = "security-framework" -version = "3.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" -dependencies = [ - "bitflags 2.11.0", - "core-foundation 0.10.1", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "selectors" version = "0.25.0" @@ -3813,27 +3633,6 @@ dependencies = [ "syn", ] -[[package]] -name = "system-configuration" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" -dependencies = [ - "bitflags 2.11.0", - "core-foundation 0.9.4", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tabular" version = "0.2.0" @@ -4047,16 +3846,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.26.4" @@ -4834,17 +4623,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" -dependencies = [ - "windows-link", - "windows-result", - "windows-strings", -] - [[package]] name = "windows-result" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index 430473c..9cf3c60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ base64 = { version = "0.22", optional = true } cooklang = { version = "0.18.4", default-features = false, features = ["aisle", "pantry"] } cooklang-find = { version = "0.5.0" } cooklang-import = "0.9.3" -cooklang-sync-client = { version = "0.4.8", optional = true } +cooklang-sync-client = { version = "0.4.11", optional = true } libsqlite3-sys = { version = "0.35", features = ["bundled"], optional = true } cooklang-language-server = "0.2.1" cooklang-reports = { version = "0.2.2" } @@ -82,7 +82,7 @@ predicates = "3" insta = { version = "1", features = ["yaml", "json", "filters"] } strip-ansi-escapes = "0.2" tokio = { version = "1", features = ["full", "test-util"] } -reqwest = { version = "0.12", features = ["json", "rustls-tls"] } +reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } [profile.release] strip = true diff --git a/src/server/sync/runner.rs b/src/server/sync/runner.rs index 7a0d7ae..220c845 100644 --- a/src/server/sync/runner.rs +++ b/src/server/sync/runner.rs @@ -1,6 +1,7 @@ use super::endpoints; use super::session::{self, SyncSession}; use anyhow::{Context, Result}; +use cooklang_sync_client::SyncContext; use std::path::Path; use std::sync::Arc; use tokio::task::JoinHandle; @@ -8,7 +9,7 @@ use tokio_util::sync::CancellationToken; /// Holds the running sync task handle and cancellation token. pub struct SyncHandle { - cancel: CancellationToken, + context: Arc, task: JoinHandle<()>, } @@ -20,7 +21,7 @@ impl SyncHandle { /// Stop the sync task gracefully. pub async fn stop(self) { - self.cancel.cancel(); + self.context.cancel(); let timeout = tokio::time::Duration::from_secs(2); match tokio::time::timeout(timeout, self.task).await { Ok(Ok(())) => tracing::info!("Sync task stopped"), @@ -36,8 +37,7 @@ pub fn start_sync( recipes_dir: String, db_path: String, ) -> Result { - let token = CancellationToken::new(); - let child_token = token.child_token(); + let context = SyncContext::new(); let jwt = session.jwt.clone(); let namespace_id: i32 = session .user_id @@ -47,10 +47,10 @@ pub fn start_sync( tracing::info!("Starting sync for directory: {recipes_dir}"); + let ctx = context.clone(); let task = tokio::spawn(async move { let result = cooklang_sync_client::run_async( - child_token, - None, + ctx, &recipes_dir, &db_path, &sync_ep, @@ -66,10 +66,7 @@ pub fn start_sync( } }); - Ok(SyncHandle { - cancel: token, - task, - }) + Ok(SyncHandle { context, task }) } /// Start a background token refresh task. Checks hourly, refreshes if < 1 hour remaining.