diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-05-17 19:27:16 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-05-17 19:27:16 -0400 |
commit | 8e2d8b97f047e6d79a3e424ba0dc611388cb65cd (patch) | |
tree | 94631f33593d0a4417dd7a6f8dd54b31a9a01460 /src/SMAPI.Web/Framework | |
parent | 4eebd813f239267d659f3cbf4fa6cf5d47d99c26 (diff) | |
download | SMAPI-8e2d8b97f047e6d79a3e424ba0dc611388cb65cd.tar.gz SMAPI-8e2d8b97f047e6d79a3e424ba0dc611388cb65cd.tar.bz2 SMAPI-8e2d8b97f047e6d79a3e424ba0dc611388cb65cd.zip |
fix mod update checks failing if a mod only has prerelease versions on GitHub
Diffstat (limited to 'src/SMAPI.Web/Framework')
-rw-r--r-- | src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs index b12b24e2..f4abd379 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/GitHubRepository.cs @@ -38,21 +38,25 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories // fetch info try { - // get latest release + // get latest release (whether preview or stable) GitRelease latest = await this.Client.GetLatestReleaseAsync(id, includePrerelease: true); - GitRelease preview = null; if (latest == null) return new ModInfoModel("Found no mod with this ID."); - // get latest stable release (if not latest) + // split stable/prerelease if applicable + GitRelease preview = null; if (latest.IsPrerelease) { - preview = latest; - latest = await this.Client.GetLatestReleaseAsync(id, includePrerelease: false); + GitRelease result = await this.Client.GetLatestReleaseAsync(id, includePrerelease: false); + if (result != null) + { + preview = latest; + latest = result; + } } // return data - return new ModInfoModel(name: id, version: this.NormaliseVersion(latest?.Tag), previewVersion: this.NormaliseVersion(preview?.Tag), url: $"https://github.com/{id}/releases"); + return new ModInfoModel(name: id, version: this.NormaliseVersion(latest.Tag), previewVersion: this.NormaliseVersion(preview?.Tag), url: $"https://github.com/{id}/releases"); } catch (Exception ex) { |