Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fix GitHub download priority
Greedeks3dc24c6b57f2
diff --git a/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs b/.Source/GTweak/Utilities/Configuration/NetworkProvider.csindex 4b112754..74b8f6e0 100644--- a/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs+++ b/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs@@ -174,39 +174,42 @@ namespace GTweak.Utilities.Configurationrequest.Headers.Add("User-Agent", "GTweak");request.Headers.Add("Accept", "application/json");- using HttpResponseMessage response = await sharedClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);- response.EnsureSuccessStatusCode();-- string json = await response.Content.ReadAsStringAsync();- GitMetadata latest = null;-- if (api.Contains("github"))- {- latest = JsonConvert.DeserializeObject<GitMetadata>(json);- }- else+ using HttpResponseMessage response = await sharedClient.SendAsync(request);+ if (response.IsSuccessStatusCode){- List<GitLabMetadata> releases = JsonConvert.DeserializeObject<List<GitLabMetadata>>(json);- latest = releases?.FirstOrDefault();+ string json = await response.Content.ReadAsStringAsync();+ string foundVersion = string.Empty, foundUrl = string.Empty;- if (latest is GitLabMetadata gitLabMetadata && !string.IsNullOrEmpty(gitLabMetadata.Description))+ if (api.Contains("github")){- Match match = Regex.Match(gitLabMetadata.Description, @"\[(?<name>.*?)\]\(/uploads/(?<hash>.+?)\)");-- if (match.Success)+ GitMetadata latest = JsonConvert.DeserializeObject<GitMetadata>(json);+ foundVersion = latest?.CurrentVersion;+ foundUrl = PathLocator.Links.LatestUpdate.GitHub;+ }+ else+ {+ List<GitLabMetadata> releases = JsonConvert.DeserializeObject<List<GitLabMetadata>>(json);+ GitLabMetadata latest = releases?.FirstOrDefault();+ if (latest != null){- string hashFile = match.Groups["hash"].Value;- PathLocator.Links.GitLabLatest = (true, $"{PathLocator.Links.GitLabLatest.Url}{hashFile}");+ foundVersion = latest.CurrentVersion;+ Match match = Regex.Match(latest.Description ?? "", @"\[.*?\]\(/uploads/(?<hash>.+?)\)");+ if (match.Success)+ {+ foundUrl = $"{PathLocator.Links.LatestUpdate.GitLabBase}{match.Groups["hash"].Value}";+ }}}- }- if (latest != null && !string.IsNullOrWhiteSpace(latest.CurrentVersion))- {- if (new Version(latest.CurrentVersion) > new Version(SettingsEngine.CurrentRelease.Short))+ if (!string.IsNullOrEmpty(foundUrl)){- IsNeedUpdate = true;- DownloadVersion = latest.CurrentVersion;+ PathLocator.Links.LatestUpdate.Resolved = foundUrl;++ if (new Version(foundVersion) > new Version(SettingsEngine.CurrentRelease.Short))+ {+ IsNeedUpdate = true;+ DownloadVersion = foundVersion;+ }break;}}diff --git a/.Source/GTweak/Utilities/Controls/PathLocator.cs b/.Source/GTweak/Utilities/Controls/PathLocator.csindex 027089cf..50092e94 100644--- a/.Source/GTweak/Utilities/Controls/PathLocator.cs+++ b/.Source/GTweak/Utilities/Controls/PathLocator.cs@@ -338,9 +338,7 @@ namespace GTweak.Utilities.Controlsinternal const string Steam = "https://steamcommunity.com/id/greedeks/";- internal const string GitHubLatest = "https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe";-- internal static (bool Created, string Url) GitLabLatest = (false, "https://gitlab.com/-/project/79375382/uploads/");+ internal static (string GitHub, string GitLabBase, string Resolved) LatestUpdate = ("https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe", "https://gitlab.com/-/project/79375382/uploads/", GitHub);internal static readonly IReadOnlyList<string> ReleaseApi = Array.AsReadOnly(new[]{diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csindex 4c29505b..2c72bcd0 100644--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -44,7 +44,7 @@ namespace GTweak.Windows{CommandExecutor.RunCommand($"/c taskkill /f /im \"{SettingsEngine.CurrentName}\" && timeout /t 2 && del \"{SettingsEngine.CurrentLocation}\" && ren {tempFileName} \"{SettingsEngine.CurrentName}\" && \"{SettingsEngine.CurrentLocation}\"");};- webClient.DownloadFileAsync(new Uri(PathLocator.Links.GitLabLatest.Created == false ? PathLocator.Links.GitHubLatest : PathLocator.Links.GitLabLatest.Url), tempFileName);+ webClient.DownloadFileAsync(new Uri(PathLocator.Links.LatestUpdate.Resolved), tempFileName);}catch{