From 4189e2f3faa9197e83aebd32fc0af93d46ee1a61 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 13 Sep 2020 11:59:17 -0400 Subject: add support for renewing uploaded JSON/log files --- src/SMAPI.Web/Controllers/JsonValidatorController.cs | 8 +++++--- src/SMAPI.Web/Controllers/LogParserController.cs | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Web/Controllers') diff --git a/src/SMAPI.Web/Controllers/JsonValidatorController.cs b/src/SMAPI.Web/Controllers/JsonValidatorController.cs index 6ba97749..c77a3036 100644 --- a/src/SMAPI.Web/Controllers/JsonValidatorController.cs +++ b/src/SMAPI.Web/Controllers/JsonValidatorController.cs @@ -58,7 +58,7 @@ namespace StardewModdingAPI.Web.Controllers /// Render the schema validator UI. /// The schema name with which to validate the JSON, or 'edit' to return to the edit screen. /// The stored file ID. - /// The operation to perform for the selected log ID. This can be 'edit', or any other value to view. + /// The operation to perform for the selected log ID. This can be 'edit', 'renew', or any other value to view. [HttpGet] [Route("json")] [Route("json/{schemaName}")] @@ -68,8 +68,10 @@ namespace StardewModdingAPI.Web.Controllers { // parse arguments schemaName = this.NormalizeSchemaName(schemaName); + operation = operation?.Trim().ToLower(); bool hasId = !string.IsNullOrWhiteSpace(id); - bool isEditView = !hasId || operation?.Trim().ToLower() == "edit"; + bool isEditView = !hasId || operation == "edit"; + bool renew = operation == "renew"; // build result model var result = this.GetModel(id, schemaName, isEditView); @@ -77,7 +79,7 @@ namespace StardewModdingAPI.Web.Controllers return this.View("Index", result); // fetch raw JSON - StoredFileInfo file = await this.Storage.GetAsync(id); + StoredFileInfo file = await this.Storage.GetAsync(id, renew); if (string.IsNullOrWhiteSpace(file.Content)) return this.View("Index", result.SetUploadError("The JSON file seems to be empty.")); result.SetContent(file.Content, expiry: file.Expiry, uploadWarning: file.Warning); diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs index 97c419d9..39de4b5d 100644 --- a/src/SMAPI.Web/Controllers/LogParserController.cs +++ b/src/SMAPI.Web/Controllers/LogParserController.cs @@ -40,17 +40,18 @@ namespace StardewModdingAPI.Web.Controllers /// Render the log parser UI. /// The stored file ID. /// Whether to display the raw unparsed log. + /// Whether to reset the log expiry. [HttpGet] [Route("log")] [Route("log/{id}")] - public async Task Index(string id = null, bool raw = false) + public async Task Index(string id = null, bool raw = false, bool renew = false) { // fresh page if (string.IsNullOrWhiteSpace(id)) return this.View("Index", this.GetModel(id)); // log page - StoredFileInfo file = await this.Storage.GetAsync(id); + StoredFileInfo file = await this.Storage.GetAsync(id, renew); ParsedLog log = file.Success ? new LogParser().Parse(file.Content) : new ParsedLog { IsValid = false, Error = file.Error }; -- cgit