Skip to content

Commit

Permalink
[1] Issue ID #1728, Added support for ChangeLog and Download URL rela…
Browse files Browse the repository at this point in the history
…tive to location of XML file.

[2] Issue ID #1760, Fixed issue when using local network path as a Download URL raises an exception.
[3] Issue ID #1764, Fixed 'Release Notes:' typo in UpdateForm.
[4] Issue ID #1768, Replaced String.Format with Path.Combine to prevent errors related to temporary path.
  • Loading branch information
ravibpatel committed Mar 10, 2015
1 parent 62d9677 commit 7e5b91f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 35 deletions.
5 changes: 3 additions & 2 deletions AutoUpdater.NET.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoUpdater.NET", "AutoUpdater.NET\AutoUpdater.NET.csproj", "{FB9E7E6B-B19F-4F37-A708-2996190CEF13}"
EndProject
Expand Down Expand Up @@ -36,7 +36,8 @@ Global
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Debug|x86.ActiveCfg = Debug|x86
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Debug|x86.Build.0 = Debug|x86
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Release|Any CPU.ActiveCfg = Release|x86
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Release|Any CPU.Build.0 = Release|Any CPU
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Release|Mixed Platforms.ActiveCfg = Release|x86
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Release|Mixed Platforms.Build.0 = Release|x86
{FD5AE762-C630-49F8-B814-FCF70E7838D1}.Release|x86.ActiveCfg = Release|x86
Expand Down
4 changes: 3 additions & 1 deletion AutoUpdater.NET/AutoUpdater.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\AutoUpdater.NET.XML</DocumentationFile>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>AutoUpdater.NET.pfx</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -132,6 +133,7 @@
<EmbeddedResource Include="UpdateForm.pl.resx" />
<EmbeddedResource Include="UpdateForm.resx">
<DependentUpon>UpdateForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
23 changes: 20 additions & 3 deletions AutoUpdater.NET/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@ private static void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)

XmlNode appCastChangeLog = item.SelectSingleNode("changelog");

ChangeLogURL = appCastChangeLog != null ? appCastChangeLog.InnerText : "";
ChangeLogURL = GetURL(webResponse.ResponseUri, appCastChangeLog);

XmlNode appCastUrl = item.SelectSingleNode("url");

DownloadURL = appCastUrl != null ? appCastUrl.InnerText : "";
DownloadURL = GetURL(webResponse.ResponseUri, appCastUrl);

if (IntPtr.Size.Equals(8))
{
XmlNode appCastUrl64 = item.SelectSingleNode("url64");

var downloadURL64 = appCastUrl64 != null ? appCastUrl64.InnerText : "";
var downloadURL64 = GetURL(webResponse.ResponseUri, appCastUrl64);

if(!string.IsNullOrEmpty(downloadURL64))
{
Expand Down Expand Up @@ -286,6 +286,23 @@ private static void BackgroundWorkerDoWork(object sender, DoWorkEventArgs e)
}
}

private static string GetURL(Uri baseUri, XmlNode xmlNode)
{
var temp = xmlNode != null ? xmlNode.InnerText : "";

if (!string.IsNullOrEmpty(temp) && Uri.IsWellFormedUriString(temp, UriKind.Relative))
{
Uri uri = new Uri(baseUri, temp);

if (uri.IsAbsoluteUri)
{
temp = uri.AbsoluteUri;
}
}

return temp;
}

private static void ShowUI()
{
var updateForm = new UpdateForm();
Expand Down
34 changes: 17 additions & 17 deletions AutoUpdater.NET/DownloadUpdateDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void DownloadUpdateDialogLoad(object sender, EventArgs e)

var uri = new Uri(_downloadURL);

_tempPath = string.Format(@"{0}{1}", Path.GetTempPath(), GetFileName(_downloadURL));
_tempPath = Path.Combine(Path.GetTempPath(), GetFileName(_downloadURL));

_webClient.DownloadProgressChanged += OnDownloadProgressChanged;

Expand Down Expand Up @@ -63,23 +63,25 @@ private void OnDownloadComplete(object sender, AsyncCompletedEventArgs e)
private static string GetFileName(string url)
{
var fileName = string.Empty;

var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
httpWebRequest.Method = "HEAD";
httpWebRequest.AllowAutoRedirect = false;
var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode.Equals(HttpStatusCode.Redirect) || httpWebResponse.StatusCode.Equals(HttpStatusCode.Moved) || httpWebResponse.StatusCode.Equals(HttpStatusCode.MovedPermanently))
var uri = new Uri(url);
if (uri.Scheme.Equals(Uri.UriSchemeHttp) || uri.Scheme.Equals(Uri.UriSchemeHttps))
{
if (httpWebResponse.Headers["Location"] != null)
var httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
httpWebRequest.Method = "HEAD";
httpWebRequest.AllowAutoRedirect = false;
var httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
if (httpWebResponse.StatusCode.Equals(HttpStatusCode.Redirect) ||
httpWebResponse.StatusCode.Equals(HttpStatusCode.Moved) ||
httpWebResponse.StatusCode.Equals(HttpStatusCode.MovedPermanently))
{
var location = httpWebResponse.Headers["Location"];
fileName = GetFileName(location);
return fileName;
if (httpWebResponse.Headers["Location"] != null)
{
var location = httpWebResponse.Headers["Location"];
fileName = GetFileName(location);
return fileName;
}
}
}
if (httpWebResponse.Headers["content-disposition"] != null)
{
var contentDisposition = httpWebResponse.Headers["content-disposition"];
if (!string.IsNullOrEmpty(contentDisposition))
{
Expand All @@ -95,8 +97,6 @@ private static string GetFileName(string url)
}
if (string.IsNullOrEmpty(fileName))
{
var uri = new Uri(url);

fileName = Path.GetFileName(uri.LocalPath);
}
return fileName;
Expand Down
6 changes: 3 additions & 3 deletions AutoUpdater.NET/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("RBSoft")]
[assembly: AssemblyProduct("AutoUpdater.NET")]
[assembly: AssemblyCopyright("Copyright © 2012-2014 RBSoft")]
[assembly: AssemblyCopyright("Copyright © 2012-2015 RBSoft")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]
12 changes: 6 additions & 6 deletions AutoUpdater.NET/UpdateForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<value>560, 0</value>
</data>
<data name="labelUpdate.Size" type="System.Drawing.Size, System.Drawing">
<value>325, 19</value>
<value>227, 19</value>
</data>
<data name="labelUpdate.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
Expand All @@ -169,7 +169,7 @@
<value>550, 0</value>
</data>
<data name="labelDescription.Size" type="System.Drawing.Size, System.Drawing">
<value>500, 30</value>
<value>480, 15</value>
</data>
<data name="labelDescription.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
Expand All @@ -187,11 +187,14 @@
<value>91, 90</value>
</data>
<data name="labelReleaseNotes.Size" type="System.Drawing.Size, System.Drawing">
<value>102, 17</value>
<value>98, 17</value>
</data>
<data name="labelReleaseNotes.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="labelReleaseNotes.Text" xml:space="preserve">
<value>Release Notes:</value>
</data>
<data name="buttonUpdate.Location" type="System.Drawing.Point, System.Drawing">
<value>478, 570</value>
</data>
Expand Down Expand Up @@ -826,7 +829,4 @@
<data name="$this.Text" xml:space="preserve">
<value>Software Update</value>
</data>
<data name="labelReleaseNotes.Text" xml:space="preserve">
<value>Releae Notes:</value>
</data>
</root>
1 change: 1 addition & 0 deletions AutoUpdaterTest/AutoUpdaterTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
Expand Down
6 changes: 3 additions & 3 deletions AutoUpdaterTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("RBSoft")]
[assembly: AssemblyProduct("AutoUpdaterTest")]
[assembly: AssemblyCopyright("Copyright © 2012-2014 RBSoft")]
[assembly: AssemblyCopyright("Copyright © 2012-2015 RBSoft")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyVersion("1.3.2.0")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: NeutralResourcesLanguageAttribute("en")]

0 comments on commit 7e5b91f

Please sign in to comment.