diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-07-24 18:29:50 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-14 18:54:11 -0400 |
commit | e856d5efebe12b3aa65d5868ea7baa59cc54863d (patch) | |
tree | e678510fb04ab409d1ec91e6d54761c7357264ff /src/SMAPI.Web/Controllers | |
parent | 4fb16abfe9f300b0d841a98b462967b7ca1dcbe5 (diff) | |
download | SMAPI-e856d5efebe12b3aa65d5868ea7baa59cc54863d.tar.gz SMAPI-e856d5efebe12b3aa65d5868ea7baa59cc54863d.tar.bz2 SMAPI-e856d5efebe12b3aa65d5868ea7baa59cc54863d.zip |
add remote mod status to update check info (#651)
Diffstat (limited to 'src/SMAPI.Web/Controllers')
-rw-r--r-- | src/SMAPI.Web/Controllers/ModsApiController.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index 9cffd3b3..a74d0d8a 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -245,11 +245,11 @@ namespace StardewModdingAPI.Web.Controllers // parse update key UpdateKey parsed = UpdateKey.Parse(updateKey); if (!parsed.LooksValid) - return new ModInfoModel($"The update key '{updateKey}' isn't in a valid format. It should contain the site key and mod ID like 'Nexus:541'."); + return new ModInfoModel().WithError(RemoteModStatus.DoesNotExist, $"The update key '{updateKey}' isn't in a valid format. It should contain the site key and mod ID like 'Nexus:541'."); // get matching repository if (!this.Repositories.TryGetValue(parsed.Repository, out IModRepository repository)) - return new ModInfoModel($"There's no mod site with key '{parsed.Repository}'. Expected one of [{string.Join(", ", this.Repositories.Keys)}]."); + return new ModInfoModel().WithError(RemoteModStatus.DoesNotExist, $"There's no mod site with key '{parsed.Repository}'. Expected one of [{string.Join(", ", this.Repositories.Keys)}]."); // fetch mod info return await this.Cache.GetOrCreateAsync($"{repository.VendorKey}:{parsed.ID}".ToLower(), async entry => @@ -258,11 +258,11 @@ namespace StardewModdingAPI.Web.Controllers if (result.Error == null) { if (result.Version == null) - result.Error = $"The update key '{updateKey}' matches a mod with no version number."; + result.WithError(RemoteModStatus.InvalidData, $"The update key '{updateKey}' matches a mod with no version number."); else if (!Regex.IsMatch(result.Version, this.VersionRegex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)) - result.Error = $"The update key '{updateKey}' matches a mod with invalid semantic version '{result.Version}'."; + result.WithError(RemoteModStatus.InvalidData, $"The update key '{updateKey}' matches a mod with invalid semantic version '{result.Version}'."); } - entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(result.Error == null ? this.SuccessCacheMinutes : this.ErrorCacheMinutes); + entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(result.Status == RemoteModStatus.TemporaryError ? this.ErrorCacheMinutes : this.SuccessCacheMinutes); return result; }); } |