From 70931ac1f6f68f013e25fe5437e23ad148ce23e1 Mon Sep 17 00:00:00 2001 From: Florent Michel <56166507+FlorentCLMichel@users.noreply.github.com> Date: Sun, 11 Aug 2024 21:16:40 +0100 Subject: [PATCH] Fix crash when local package is missing and make OpenSSL optional in typst-kit (#4720) --- crates/typst-kit/Cargo.toml | 4 ++-- crates/typst-kit/src/package.rs | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/typst-kit/Cargo.toml b/crates/typst-kit/Cargo.toml index 9c13ceed4..770722c62 100644 --- a/crates/typst-kit/Cargo.toml +++ b/crates/typst-kit/Cargo.toml @@ -28,7 +28,7 @@ ureq = { workspace = true, optional = true } # Explicitly depend on OpenSSL if applicable, so that we can add the # `openssl/vendored` feature to it if `vendor-openssl` is enabled. [target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos")))'.dependencies] -openssl = { workspace = true } +openssl = { workspace = true, optional = true } [features] default = ["fonts", "packages"] @@ -37,7 +37,7 @@ default = ["fonts", "packages"] fonts = ["dep:fontdb", "fontdb/memmap", "fontdb/fontconfig"] # Add generic downloading utilities -downloads = ["dep:env_proxy", "dep:native-tls", "dep:ureq"] +downloads = ["dep:env_proxy", "dep:native-tls", "dep:ureq", "dep:openssl"] # Add package downloading utilities, implies `downloads` packages = ["downloads", "dep:dirs", "dep:flate2", "dep:tar"] diff --git a/crates/typst-kit/src/package.rs b/crates/typst-kit/src/package.rs index ad69df01d..3c9e65293 100644 --- a/crates/typst-kit/src/package.rs +++ b/crates/typst-kit/src/package.rs @@ -85,9 +85,11 @@ impl PackageStorage { } // Download from network if it doesn't exist yet. - self.download_package(spec, &dir, progress)?; - if dir.exists() { - return Ok(dir); + if spec.namespace == "preview" { + self.download_package(spec, &dir, progress)?; + if dir.exists() { + return Ok(dir); + } } }