Skip to content

Commit

Permalink
Merge pull request #591 from Squirrel/fix-pinning-yet-again-srsly-i-h…
Browse files Browse the repository at this point in the history
…ate-pinning

Fix pinning yet again srsly i hate pinning
  • Loading branch information
anaisbetts committed Feb 6, 2016
2 parents 0d3c888 + a9297db commit 193dc32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
17 changes: 0 additions & 17 deletions src/Squirrel/ShellFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ public static PROPERTYKEY PKEY_AppUserModel_ID {
};
}
}

public static PROPERTYKEY PKEY_AppUserModel_RelaunchCommand {
get {
return new PROPERTYKEY() {
fmtid = Guid.ParseExact("{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}", "B"),
pid = new UIntPtr(2),
};
}
}
}

[ComImport]
Expand Down Expand Up @@ -878,14 +869,6 @@ public void SetAppUserModelId(string appId)
propStore.SetValue(ref pkey, ref str);
}

public void SetAppUserModelRelaunchCommand(string commandWithArgs)
{
var propStore = (IPropertyStore)linkW;
var pkey = PROPERTYKEY.PKEY_AppUserModel_ID;
var str = PropVariant.FromString (commandWithArgs);
propStore.SetValue(ref pkey, ref str);
}

/// <summary>
/// Saves the shortcut to ShortCutFile.
/// </summary>
Expand Down
26 changes: 14 additions & 12 deletions src/Squirrel/UpdateManager.ApplyReleases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public Dictionary<ShortcutLocation, ShellLink> GetShortcutsForExecutable(string
}

sl.SetAppUserModelId(String.Format("com.squirrel.{0}.{1}", zf.Id, exeName.Replace(".exe", "")));
sl.SetAppUserModelRelaunchCommand(String.Format("{0} {1}", sl.Target, sl.Arguments));
ret.Add(f, sl);
}

Expand Down Expand Up @@ -512,20 +511,23 @@ void updateLink(ShellLink shortcut, string newAppPath)
}

this.Log().Info("Old iconPath is: '{0}'", shortcut.IconPath);
var iconPath = Path.Combine(newAppPath, Path.GetFileName(shortcut.IconPath));
if (!File.Exists(iconPath) && targetIsUpdateDotExe) {
var executable = shortcut.Arguments.Replace("--processStart ", "");
iconPath = Path.Combine(newAppPath, executable);
}
if (!File.Exists(shortcut.IconPath) || shortcut.IconPath.IndexOf("app-", StringComparison.OrdinalIgnoreCase) > 1) {
var iconPath = Path.Combine(newAppPath, Path.GetFileName(shortcut.IconPath));

if (!File.Exists(iconPath) && targetIsUpdateDotExe) {
var executable = shortcut.Arguments.Replace("--processStart ", "");
iconPath = Path.Combine(newAppPath, executable);
}

this.Log().Info("Setting iconPath to: '{0}'", iconPath);
shortcut.IconPath = iconPath;
this.Log().Info("Setting iconPath to: '{0}'", iconPath);
shortcut.IconPath = iconPath;

if (!File.Exists(iconPath)) {
this.Log().Warn("Tried to use {0} for icon path but didn't exist, falling back to EXE", iconPath);
if (!File.Exists(iconPath)) {
this.Log().Warn("Tried to use {0} for icon path but didn't exist, falling back to EXE", iconPath);

shortcut.IconPath = target;
shortcut.IconIndex = 0;
shortcut.IconPath = target;
shortcut.IconIndex = 0;
}
}

this.ErrorIfThrows(() => Utility.Retry(() => shortcut.Save(), 2), "Couldn't write shortcut " + shortcut.ShortCutFile);
Expand Down

0 comments on commit 193dc32

Please sign in to comment.