Skip to content

Commit

Permalink
Now integrity of the downloaded file will be checked using provided c…
Browse files Browse the repository at this point in the history
…hecksum as soon as the download completes.
  • Loading branch information
ravibpatel committed Feb 10, 2018
1 parent 25e4567 commit 7989cad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent
return;
}

if (!string.IsNullOrEmpty(AutoUpdater.Checksum))
{
if (!CompareChecksum(_tempFile, AutoUpdater.Checksum))
{
_webClient = null;
Close();
return;
}
}

string fileName;
string contentDisposition = _webClient.ResponseHeaders["Content-Disposition"] ?? string.Empty;
if (string.IsNullOrEmpty(contentDisposition))
Expand Down Expand Up @@ -122,16 +132,6 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent
}
}

if (!string.IsNullOrEmpty(AutoUpdater.Checksum))
{
if (!CompareChecksum(tempPath, AutoUpdater.Checksum))
{
_webClient = null;
Close();
return;
}
}

try
{
Process.Start(processStartInfo);
Expand Down
2 changes: 1 addition & 1 deletion AutoUpdaterTest/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void FormMain_Load(object sender, EventArgs e)
//};
//timer.Start();

//AutoUpdater.Start("https://rbsoft.org/updates/AutoUpdaterTest.xml");
AutoUpdater.Start("https://rbsoft.org/updates/AutoUpdaterTest.xml");
}

private void AutoUpdater_ApplicationExitEvent()
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ var proxy = new WebProxy("ProxyIP:ProxyPort", true)
AutoUpdater.Proxy = proxy;
````

### Specify where to download update file
### Specify where to download the update file

You can specify where you want to download update file by assigning DownloadPath field as shown below. It will be used for ZipExtractor too.
You can specify where you want to download the update file by assigning DownloadPath field as shown below. It will be used for ZipExtractor too.

````csharp
AutoUpdater.DownloadPath = Environment.CurrentDirectory;
Expand Down

0 comments on commit 7989cad

Please sign in to comment.