From e7aaab5f84321b4e1800b230ebc30631382ca585 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 20 Apr 2016 10:32:08 -0700 Subject: [PATCH] Code Reviews --- src/Squirrel/ReleaseEntry.cs | 7 +++++-- src/Squirrel/UpdateManager.CheckForUpdates.cs | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Squirrel/ReleaseEntry.cs b/src/Squirrel/ReleaseEntry.cs index 0e94359b..855c82dd 100644 --- a/src/Squirrel/ReleaseEntry.cs +++ b/src/Squirrel/ReleaseEntry.cs @@ -115,7 +115,7 @@ namespace Squirrel string filename = m.Groups[2].Value; - // Split the base URL and the filename if an URI is provided, + // Split the base URL and the filename if an URI is provided, // throws if a path is provided string baseUrl = null; string query = null; @@ -137,7 +137,7 @@ namespace Squirrel query = uri.Query; } } - + if (filename.IndexOfAny(Path.GetInvalidFileNameChars()) > -1) { throw new Exception("Filename can either be an absolute HTTP[s] URL, *or* a file name"); } @@ -150,6 +150,9 @@ namespace Squirrel public bool IsStagingMatch(Guid? userId) { + // A "Staging match" is when a user falls into the affirmative + // bucket - i.e. if the staging is at 10%, this user is the one out + // of ten case. if (!StagingPercentage.HasValue) return true; if (!userId.HasValue) return false; diff --git a/src/Squirrel/UpdateManager.CheckForUpdates.cs b/src/Squirrel/UpdateManager.CheckForUpdates.cs index c4030fc3..b4782415 100644 --- a/src/Squirrel/UpdateManager.CheckForUpdates.cs +++ b/src/Squirrel/UpdateManager.CheckForUpdates.cs @@ -23,7 +23,7 @@ namespace Squirrel public async Task CheckForUpdate( string localReleaseFile, string updateUrlOrPath, - bool ignoreDeltaUpdates = false, + bool ignoreDeltaUpdates = false, Action progress = null, IFileDownloader urlDownloader = null) { @@ -45,11 +45,11 @@ namespace Squirrel string releaseFile; - var latestLocalRelease = localReleases.Count() > 0 ? - localReleases.MaxBy(x => x.Version).First() : + 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 + // Fetch the remote RELEASES file, whether it's a local dir or an // HTTP URL if (Utility.IsHttpUrl(updateUrlOrPath)) { if (updateUrlOrPath.EndsWith("/")) { @@ -89,7 +89,7 @@ namespace Squirrel if (!Directory.Exists(updateUrlOrPath)) { var message = String.Format( - "The directory {0} does not exist, something is probably broken with your application", + "The directory {0} does not exist, something is probably broken with your application", updateUrlOrPath); throw new Exception(message); @@ -98,7 +98,7 @@ namespace Squirrel var fi = new FileInfo(Path.Combine(updateUrlOrPath, "RELEASES")); if (!fi.Exists) { var message = String.Format( - "The file {0} does not exist, something is probably broken with your application", + "The file {0} does not exist, something is probably broken with your application", fi.FullName); this.Log().Warn(message); @@ -118,7 +118,7 @@ namespace Squirrel } var ret = default(UpdateInfo); - var remoteReleases = ReleaseEntry.ParseReleaseFileAndApplyStaging(releaseFile, stagingId); + var remoteReleases = ReleaseEntry.ParseReleaseFileAndApplyStaging(releaseFile, stagingId); progress(66); if (!remoteReleases.Any()) { @@ -126,7 +126,7 @@ namespace Squirrel } ret = determineUpdateInfo(localReleases, remoteReleases, ignoreDeltaUpdates); - + progress(100); return ret; } @@ -192,7 +192,7 @@ namespace Squirrel this.Log().Info("Using existing staging user ID: {0}", ret.ToString()); return ret; } catch (Exception ex) { - this.Log().InfoException("Couldn't read staging user ID, creating a blank one", ex); + this.Log().DebugException("Couldn't read staging user ID, creating a blank one", ex); } var prng = new Random();