Skip to content

Commit

Permalink
correct path
Browse files Browse the repository at this point in the history
  • Loading branch information
voltura committed Feb 18, 2024
1 parent d01f8b1 commit 2c1ef5b
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.WebRequestMethods;

#endregion Using statements

Expand All @@ -16,7 +17,7 @@ internal sealed class UpdateHandler
{
#region Private constants

private static readonly string VERSION_CHECK_BASE_URL = "http://github.com/voltura/weeknumber/releases/latest/download/";
private static readonly string VERSION_CHECK_BASE_URL = "https://github.com/voltura/WeekNumber/releases/latest/download/";
private static readonly string VERSION_CHECK_URL = $"{VERSION_CHECK_BASE_URL}VERSION.TXT";
internal static readonly string APPLICATION_URL = "https://voltura.github.io/WeekNumber/";

Expand Down Expand Up @@ -119,14 +120,14 @@ internal void PerformUpdateCheck(bool silent = false)
}
try
{
if (File.Exists(destinationFullPath) &&
File.Exists(destinationFullPath + ".MD5"))
if (System.IO.File.Exists(destinationFullPath) &&
System.IO.File.Exists(destinationFullPath + ".MD5"))
{
//remove smartscreen filter (alternative data stream Zone.Identifier) on downloaded installer executable file
UnblockFile(destinationFullPath);
//validate installer checksum
string installerMD5 = CalculateMD5(destinationFullPath);
string installerInternetMD5 = File.ReadAllText(destinationFullPath + ".MD5").PadRight(32).Substring(0, 32);
string installerInternetMD5 = System.IO.File.ReadAllText(destinationFullPath + ".MD5").PadRight(32).Substring(0, 32);
if (installerMD5 != installerInternetMD5)
{
LogAndShow($@"{Resources.FailedAutoInstall}
Expand Down Expand Up @@ -235,7 +236,7 @@ private VersionInfo GetInternetVersion(bool silent)
{
// The URI formed by combining System.Net.WebClient.BaseAddress and address is invalid.-or-
// An error occurred while downloading the resource.
LogAndShow($@"{Resources.FailedToPerformVersionCheck}
LogAndShow($@"{Resources.FailedToPerformVersionCheck}
{Resources.CheckBrowserNavigation}
{VERSION_CHECK_BASE_URL}", silent, we);
Expand Down Expand Up @@ -292,9 +293,9 @@ private bool DownloadFile(string source, string destination)
Log.LogCaller();
try
{
if (File.Exists(destination)) File.Delete(destination);
if (System.IO.File.Exists(destination)) System.IO.File.Delete(destination);
Task.Run(async () => { await new WebClient().DownloadFileTaskAsync(new Uri(source), destination); }).Wait();
return File.Exists(destination);
return System.IO.File.Exists(destination);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -360,11 +361,11 @@ private static string CalculateMD5(string filename)
string fileMD5Hash = string.Empty;
try
{
if (File.Exists(filename))
if (System.IO.File.Exists(filename))
{
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
{
using (FileStream stream = File.OpenRead(filename))
using (FileStream stream = System.IO.File.OpenRead(filename))
{
byte[] hash = md5.ComputeHash(stream);
fileMD5Hash = BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
Expand All @@ -385,7 +386,7 @@ private static string CalculateMD5(string filename)
}

/// <summary>
/// Removes Zone Identification tagging that are using Alternate Data Streams (Zone.Identifier) created on file
/// Removes Zone Identification tagging that are using Alternate Data Streams (Zone.Identifier) created on file
/// when downloaded from internet, also called 'Mark of the Web'
/// Allows to execute file without Microsoft Defender SmartScreen interferance.
/// See https://www.winhelponline.com/blog/bulk-unblock-files-downloaded-internet/ for more info
Expand All @@ -398,7 +399,7 @@ private static bool UnblockFile(string fullPath)
string parameters = @"-Command ""& {Unblock-File -Path """ + fullPath + @""" }""";
try
{
if (!File.Exists(fullPath))
if (!System.IO.File.Exists(fullPath))
{
Log.ErrorString = $"File '{fullPath}' not found.";
return result;
Expand Down

0 comments on commit 2c1ef5b

Please sign in to comment.