Skip to content

Commit 3ab1709

Browse files
feat(nsis): add an option to disable compression (#9932)
1 parent 656a649 commit 3ab1709

File tree

9 files changed

+81
-44
lines changed

9 files changed

+81
-44
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch:breaking
3+
---
4+
5+
Changed `NsisSettings::compression` field from `Option<NsisCompression>` to just `NsisCompression`

.changes/nsis-no-compression.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-utils": patch:feat
3+
"tauri-bundler": patch:feat
4+
---
5+
6+
Add an option to disable NSIS compression `bundle > nsis > compression: "none"`
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch:breaking
3+
---
4+
5+
Changed `NsisConfig::compression` field from `Option<NsisCompression>` to just `NsisCompression`

core/tauri-config-schema/schema.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,12 +2299,10 @@
22992299
},
23002300
"compression": {
23012301
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
2302-
"anyOf": [
2302+
"default": "lzma",
2303+
"allOf": [
23032304
{
23042305
"$ref": "#/definitions/NsisCompression"
2305-
},
2306-
{
2307-
"type": "null"
23082306
}
23092307
]
23102308
},
@@ -2367,6 +2365,13 @@
23672365
"enum": [
23682366
"lzma"
23692367
]
2368+
},
2369+
{
2370+
"description": "Disable compression",
2371+
"type": "string",
2372+
"enum": [
2373+
"none"
2374+
]
23702375
}
23712376
]
23722377
},

core/tauri-utils/src/config.rs

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,44 @@ pub enum NsisCompression {
691691
Bzip2,
692692
/// LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
693693
Lzma,
694+
/// Disable compression
695+
None,
696+
}
697+
698+
impl Default for NsisCompression {
699+
fn default() -> Self {
700+
Self::Lzma
701+
}
702+
}
703+
704+
/// Install Modes for the NSIS installer.
705+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
706+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
707+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
708+
pub enum NSISInstallerMode {
709+
/// Default mode for the installer.
710+
///
711+
/// Install the app by default in a directory that doesn't require Administrator access.
712+
///
713+
/// Installer metadata will be saved under the `HKCU` registry path.
714+
CurrentUser,
715+
/// Install the app by default in the `Program Files` folder directory requires Administrator
716+
/// access for the installation.
717+
///
718+
/// Installer metadata will be saved under the `HKLM` registry path.
719+
PerMachine,
720+
/// Combines both modes and allows the user to choose at install time
721+
/// whether to install for the current user or per machine. Note that this mode
722+
/// will require Administrator access even if the user wants to install it for the current user only.
723+
///
724+
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
725+
Both,
726+
}
727+
728+
impl Default for NSISInstallerMode {
729+
fn default() -> Self {
730+
Self::CurrentUser
731+
}
694732
}
695733

696734
/// Configuration for the Installer bundle using NSIS.
@@ -736,7 +774,8 @@ pub struct NsisConfig {
736774
/// Set the compression algorithm used to compress files in the installer.
737775
///
738776
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
739-
pub compression: Option<NsisCompression>,
777+
#[serde(default)]
778+
pub compression: NsisCompression,
740779
/// A path to a `.nsh` file that contains special NSIS macros to be hooked into the
741780
/// main installer.nsi script.
742781
///
@@ -775,36 +814,6 @@ pub struct NsisConfig {
775814
pub installer_hooks: Option<PathBuf>,
776815
}
777816

778-
/// Install Modes for the NSIS installer.
779-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
780-
#[serde(rename_all = "camelCase", deny_unknown_fields)]
781-
#[cfg_attr(feature = "schema", derive(JsonSchema))]
782-
pub enum NSISInstallerMode {
783-
/// Default mode for the installer.
784-
///
785-
/// Install the app by default in a directory that doesn't require Administrator access.
786-
///
787-
/// Installer metadata will be saved under the `HKCU` registry path.
788-
CurrentUser,
789-
/// Install the app by default in the `Program Files` folder directory requires Administrator
790-
/// access for the installation.
791-
///
792-
/// Installer metadata will be saved under the `HKLM` registry path.
793-
PerMachine,
794-
/// Combines both modes and allows the user to choose at install time
795-
/// whether to install for the current user or per machine. Note that this mode
796-
/// will require Administrator access even if the user wants to install it for the current user only.
797-
///
798-
/// Installer metadata will be saved under the `HKLM` or `HKCU` registry path based on the user's choice.
799-
Both,
800-
}
801-
802-
impl Default for NSISInstallerMode {
803-
fn default() -> Self {
804-
Self::CurrentUser
805-
}
806-
}
807-
808817
/// Install modes for the Webview2 runtime.
809818
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
810819
///

tooling/bundler/src/bundle/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub struct NsisSettings {
416416
/// By default the OS language is selected, with a fallback to the first language in the `languages` array.
417417
pub display_language_selector: bool,
418418
/// Set compression algorithm used to compress files in the installer.
419-
pub compression: Option<NsisCompression>,
419+
pub compression: NsisCompression,
420420
/// A path to a `.nsh` file that contains special NSIS macros to be hooked into the
421421
/// main installer.nsi script.
422422
///

tooling/bundler/src/bundle/windows/nsis.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,11 @@ fn build_nsis_app_installer(
247247

248248
data.insert(
249249
"compression",
250-
to_json(match &nsis.compression.unwrap_or(NsisCompression::Lzma) {
250+
to_json(match &nsis.compression {
251251
NsisCompression::Zlib => "zlib",
252252
NsisCompression::Bzip2 => "bzip2",
253253
NsisCompression::Lzma => "lzma",
254+
NsisCompression::None => "none",
254255
}),
255256
);
256257

tooling/bundler/src/bundle/windows/templates/installer.nsi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
Unicode true
22
ManifestDPIAware true
3-
; Set the compression algorithm. Default is LZMA.
4-
!if "{{compression}}" == ""
5-
SetCompressor /SOLID lzma
3+
4+
!if "{{compression}}" == "none"
5+
SetCompress false
66
!else
7+
; Set the compression algorithm. Default is LZMA.
78
SetCompressor /SOLID "{{compression}}"
89
!endif
910

tooling/cli/schema.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,12 +2299,10 @@
22992299
},
23002300
"compression": {
23012301
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
2302-
"anyOf": [
2302+
"default": "lzma",
2303+
"allOf": [
23032304
{
23042305
"$ref": "#/definitions/NsisCompression"
2305-
},
2306-
{
2307-
"type": "null"
23082306
}
23092307
]
23102308
},
@@ -2367,6 +2365,13 @@
23672365
"enum": [
23682366
"lzma"
23692367
]
2368+
},
2369+
{
2370+
"description": "Disable compression",
2371+
"type": "string",
2372+
"enum": [
2373+
"none"
2374+
]
23702375
}
23712376
]
23722377
},

0 commit comments

Comments
 (0)