Skip to content

Commit

Permalink
Merge pull request #428 from Squirrel/release-info
Browse files Browse the repository at this point in the history
Add local version information as query string to URL
  • Loading branch information
anaisbetts committed Sep 4, 2015
2 parents b732b80 + a256f8c commit 6ecddc4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Squirrel/UpdateManager.CheckForUpdates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public async Task<UpdateInfo> CheckForUpdate(

string releaseFile;

var latestLocalRelease = localReleases.Count() > 0 ?
localReleases.MaxBy(x => x.Version).First() :
default(ReleaseEntry);

// Fetch the remote RELEASES file, whether it's a local dir or an
// HTTP URL
if (Utility.IsHttpUrl(updateUrlOrPath)) {
Expand All @@ -58,7 +62,16 @@ public async Task<UpdateInfo> CheckForUpdate(
retry:

try {
var data = await urlDownloader.DownloadUrl(String.Format("{0}/{1}", updateUrlOrPath, "RELEASES"));
var url = String.Format("{0}/{1}", updateUrlOrPath, "RELEASES");
if (latestLocalRelease != null) {
url = String.Format("{0}/RELEASES?id={1}&localVersion={2}&arch={3}",
updateUrlOrPath,
Uri.EscapeUriString(latestLocalRelease.PackageName),
Uri.EscapeUriString(latestLocalRelease.Version.ToString()),
Environment.Is64BitOperatingSystem ? "amd64" : "x86");
}

var data = await urlDownloader.DownloadUrl(url);
releaseFile = Encoding.UTF8.GetString(data);
} catch (WebException ex) {
this.Log().InfoException("Download resulted in WebException (returning blank release list)", ex);
Expand Down

0 comments on commit 6ecddc4

Please sign in to comment.