Skip to content

Commit

Permalink
fix(nsis): esitmated size unit (#10086)
Browse files Browse the repository at this point in the history
* Fix nsis esitmated size unit

* Add change file
  • Loading branch information
Legend-Master authored Jun 19, 2024
1 parent 3bbfac8 commit 58821fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/nsis-esitimated-size-unit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-bundler": "patch:bug"
---

Fix NSIS esitmated size unit being in kB (1000 bytes) not KB (1024 bytes)
21 changes: 10 additions & 11 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,21 +661,20 @@ fn generate_binaries_data(settings: &Settings) -> crate::Result<BinariesMap> {
}

fn generate_estimated_size(
main: &Path,
main: &PathBuf,
binaries: &BinariesMap,
resources: &ResourcesMap,
) -> crate::Result<String> {
use std::fs::metadata;

let mut size = metadata(main)?.len();

for k in binaries.keys().chain(resources.keys()) {
size += metadata(k)?.len();
let mut size = 0;
for k in std::iter::once(main)
.chain(binaries.keys())
.chain(resources.keys())
{
size += std::fs::metadata(k)
.with_context(|| format!("when getting size of {}", main.display()))?
.len();
}

size /= 1000;

Ok(format!("{size:#08x}"))
Ok(format!("{:#08x}", size / 1024))
}

fn get_lang_data(lang: &str) -> Option<(String, &[u8])> {
Expand Down

0 comments on commit 58821fc

Please sign in to comment.