Skip to content

Commit

Permalink
Fix for #11
Browse files Browse the repository at this point in the history
  • Loading branch information
theolivenbaum committed Feb 13, 2023
1 parent c70f86e commit f53255c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
34 changes: 7 additions & 27 deletions ElectronSharp.API/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public event Action<string> OnError
{
BridgeConnector.On<string>("autoUpdater-error" + GetHashCode(), (message) =>
{
_error(message.ToString());
_error(message);
});

BridgeConnector.Emit("register-autoUpdater-error-event", GetHashCode());
Expand Down Expand Up @@ -363,7 +363,7 @@ public Task<UpdateCheckResult> CheckForUpdatesAsync()
BridgeConnector.Off("autoUpdaterCheckForUpdatesComplete" + guid);
BridgeConnector.Off("autoUpdaterCheckForUpdatesError" + guid);
string message = "An error occurred in CheckForUpdatesAsync";
if (error != null && !string.IsNullOrEmpty(error.ToString()))
if (!string.IsNullOrEmpty(error))
message = JsonConvert.SerializeObject(error);
taskCompletionSource.SetException(new Exception(message));
});
Expand Down Expand Up @@ -433,41 +433,21 @@ public void QuitAndInstall(bool isSilent = false, bool isForceRunAfter = false)
/// <summary>
/// Start downloading update manually. You can use this method if "AutoDownload" option is set to "false".
/// </summary>
/// <returns>Path to downloaded file.</returns>
public Task<string> DownloadUpdateAsync()
/// <returns>Paths to downloaded files.</returns>
public Task<string[]> DownloadUpdateAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
var taskCompletionSource = new TaskCompletionSource<string[]>(TaskCreationOptions.RunContinuationsAsynchronously);
string guid = Guid.NewGuid().ToString();

BridgeConnector.On<string>("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPath) =>
BridgeConnector.On<string[]>("autoUpdaterDownloadUpdateComplete" + guid, (downloadedPaths) =>
{
BridgeConnector.Off("autoUpdaterDownloadUpdateComplete" + guid);
taskCompletionSource.SetResult(downloadedPath.ToString());
taskCompletionSource.SetResult(downloadedPaths);
});

BridgeConnector.Emit("autoUpdaterDownloadUpdate", guid);

return taskCompletionSource.Task;
}

/// <summary>
/// Feed URL.
/// </summary>
/// <returns>Feed URL.</returns>
public Task<string> GetFeedURLAsync()
{
var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
string guid = Guid.NewGuid().ToString();

BridgeConnector.On<string>("autoUpdaterGetFeedURLComplete" + guid, (downloadedPath) =>
{
BridgeConnector.Off("autoUpdaterGetFeedURLComplete" + guid);
taskCompletionSource.SetResult(downloadedPath.ToString());
});

BridgeConnector.Emit("autoUpdaterGetFeedURL", guid);

return taskCompletionSource.Task;
}
}
}
4 changes: 0 additions & 4 deletions ElectronSharp.Host/api/autoUpdater.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions ElectronSharp.Host/api/autoUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,4 @@ export = (socket: Socket, app: Electron.App) => {
const downloadedPath = await autoUpdater.downloadUpdate();
electronSocket.emit('autoUpdaterDownloadUpdateComplete' + guid, downloadedPath);
});

socket.on('autoUpdaterGetFeedURL', async (guid) => {
const feedUrl = await autoUpdater.getFeedURL();
electronSocket.emit('autoUpdaterGetFeedURLComplete' + guid, feedUrl || '');
});
};

0 comments on commit f53255c

Please sign in to comment.