1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-21 13:38:56 +02:00

Webview2 installer cleanup

This commit is contained in:
Chen-I Lim 2021-03-01 16:24:38 -08:00
parent da6ffd3eb0
commit a3d6439166

View File

@ -20,9 +20,9 @@ namespace Focalboard {
private string filePath; private string filePath;
public Webview2Installer() { public Webview2Installer() {
const string filename = "MicrosoftEdgeWebview2Setup.exe"; var filename = $"{Guid.NewGuid().ToString()} MicrosoftEdgeWebview2Setup.exe";
var downloadsFolder = UserDataPaths.GetDefault().Downloads; filePath = Path.Combine(System.IO.Path.GetTempPath(), filename);
filePath = Path.Combine(downloadsFolder, filename); Debug.WriteLine($"Webview2Installer.filePath: {filePath}");
} }
public void DownloadAndInstall() { public void DownloadAndInstall() {
@ -39,7 +39,7 @@ namespace Focalboard {
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged); wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted); wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
} catch (Exception ex) { } catch (Exception ex) {
MessageBox.Show(ex.Message.ToString()); MessageBox.Show($"Webview2 download ERROR: {ex.Message}", "Download error");
} }
} }
@ -59,6 +59,15 @@ namespace Focalboard {
} }
private void Proc_Exited(object sender, EventArgs e) { private void Proc_Exited(object sender, EventArgs e) {
// Delete downloaded installer
try {
if (File.Exists(filePath)) {
File.Delete(filePath);
}
} catch (Exception ex) {
Debug.WriteLine($"Delete file failed. Error: {ex.Message}, filePath: {filePath}");
}
var proc = (Process)sender; var proc = (Process)sender;
exitCode = proc.ExitCode; exitCode = proc.ExitCode;
InstallCompleted?.Invoke(this, e); InstallCompleted?.Invoke(this, e);