Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Better package size estimate for uninstall entry
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Dec 14, 2021
1 parent 80411fd commit 517aaed
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Squirrel/UpdateManager.InstallHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
Expand Down Expand Up @@ -79,8 +79,15 @@ public async Task<RegistryKey> CreateUninstallerRegistryEntry(string uninstallCm
new { Key = "URLUpdateInfo", Value = zp.ProjectUrl != null ? zp.ProjectUrl.ToString() : "", }
};

// CS: very rough estimate of installed size. based on a few assumptions:
// - zip generally achieves a ~62% compression ratio on this kind of data
// - we usually keep 2 copies of the extracted app (the current, and previous version)
// - we keep a copy of the compressed package, as well as the extracted package on disk for the latest version
var compressedSizeInKb = new FileInfo(pkgPath).Length / 1024;
var estimatedInstallInKb = compressedSizeInKb + (compressedSizeInKb / 0.38d * 2);

var dwordsToWrite = new[] {
new { Key = "EstimatedSize", Value = (int)((new FileInfo(pkgPath)).Length / 1024) },
new { Key = "EstimatedSize", Value = (int)estimatedInstallInKb },
new { Key = "NoModify", Value = 1 },
new { Key = "NoRepair", Value = 1 },
new { Key = "Language", Value = 0x0409 },
Expand Down

0 comments on commit 517aaed

Please sign in to comment.