Skip to content

Commit

Permalink
boost(AutoUpdate): Keep the Update in a Temp folder with the real nam…
Browse files Browse the repository at this point in the history
…e of the file. Let windows clean them up later.

Fixes SOUNDSWITCH-5Y
  • Loading branch information
Belphemur committed Jun 26, 2022
1 parent d4894a0 commit 59274db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions SoundSwitch.Audio.Manager/AudioSwitcher.cs
Expand Up @@ -119,6 +119,11 @@ public void SwitchProcessTo(string deviceId, ERole role, EDataFlow flow, uint pr
Trace.TraceInformation($"Attempt to switch [{processId}] but got exception: {e}");
return;
}
catch (ArgumentException e)
{
Trace.TraceInformation($"Attempt to switch [{processId}] but got exception: {e}");
return;
}
catch (Exception e)
{
Trace.TraceError($"Can't get process info: {e}");
Expand Down
9 changes: 2 additions & 7 deletions SoundSwitch/Framework/Updater/AutoUpdater.cs
Expand Up @@ -13,7 +13,6 @@
********************************************************************/

using System;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Serilog;
Expand All @@ -30,23 +29,19 @@ public class AutoUpdater
{
private readonly SynchronizationContext _context = SynchronizationContext.Current ?? new SynchronizationContext();
public string InstallerParameters { get; }
public string InstallerFilePath { get; }

/// <summary>
/// Constructor of the AutoUpdater
/// </summary>
/// <param name="installerParameters">Parameters given to the installer after downloading it</param>
/// <param name="filePath">Where to download the Installer without the filename</param>
public AutoUpdater(string installerParameters, string filePath)
public AutoUpdater(string installerParameters)
{
InstallerParameters = installerParameters;
InstallerFilePath = Path.Combine(filePath, "SoundSwitch_Update.exe");
}

public void Update(AppRelease appRelease, bool closeApp)
{

var file = new WebFile(new Uri(appRelease.Asset.BrowserDownloadUrl), InstallerFilePath);
var file = new WebFile(new Uri(appRelease.Asset.BrowserDownloadUrl));
file.Downloaded += (sender, args) =>
{
Log.Information("Update downloaded: {File}", file);
Expand Down
3 changes: 1 addition & 2 deletions SoundSwitch/Model/SoundSwitchApplicationContext.cs
Expand Up @@ -2,7 +2,6 @@
using NAudio.CoreAudioApi;
using Serilog;
using SoundSwitch.Common.Framework.Audio.Device;
using SoundSwitch.Framework;
using SoundSwitch.Framework.Audio.Lister;
using SoundSwitch.Framework.Banner;
using SoundSwitch.Framework.Configuration;
Expand Down Expand Up @@ -31,7 +30,7 @@ public SoundSwitchApplicationContext()
{
if (@event.UpdateMode == UpdateMode.Silent)
{
new AutoUpdater("/VERYSILENT", ApplicationPath.Default).Update(
new AutoUpdater("/VERYSILENT").Update(
@event.AppRelease, true);
}
};
Expand Down

0 comments on commit 59274db

Please sign in to comment.