Skip to content

Commit

Permalink
fix: duplicate records in Uninst.dat #5
Browse files Browse the repository at this point in the history
  • Loading branch information
emako committed Oct 7, 2024
1 parent 818c43b commit 951c281
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions build/MicaSetup/Helper/Setup/InstallHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using SharpCompress.Common;
using SharpCompress.Readers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

Expand Down Expand Up @@ -119,13 +120,12 @@ public static void Install(Stream archiveStream, Action<double, string> progress
PreserveFileTime = true,
};

StringBuilder uninstallData = new();
HashSet<string> uninstallData = [];
ArchiveFileHelper.ExtractAll(Option.Current.InstallLocation, archiveStream, (double progress, string key) =>
{
Logger.Debug($"[ExtractAll] {key} {progress * 100d:0.00}%");
progressCallback?.Invoke(progress, key);
uninstallData.Append(key);
uninstallData.Append('|'); // The '|' is a good split char for file path.
uninstallData.Add(key);
}, readerOptions: readerOptions, options: extractionOptions);

if (Option.Current.IsCreateRegistryKeys && RuntimeHelper.IsElevated)
Expand All @@ -150,7 +150,7 @@ public static void Install(Stream archiveStream, Action<double, string> progress
info.DisplayIcon = Path.Combine(Option.Current.InstallLocation, Option.Current.DisplayIcon);
}
info.UninstallString ??= Path.Combine(Option.Current.InstallLocation, "Uninst.exe");
info.UninstallData = uninstallData.ToString();
info.UninstallData = string.Join("|", uninstallData); // The '|' is a good split char for file path.

try
{
Expand All @@ -172,7 +172,7 @@ public static void Install(Stream archiveStream, Action<double, string> progress
// Not allow user file named the same as it.
File.Delete(uninstDataPath);
}
File.WriteAllText(uninstDataPath, uninstallData.ToString());
File.WriteAllText(uninstDataPath, string.Join("|", uninstallData)); // The '|' is a good split char for file path.
}
catch (Exception e)
{
Expand Down

0 comments on commit 951c281

Please sign in to comment.