From 4d2f887517af440a6f04bf6f930fa3386c280ee0 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Fri, 10 Jan 2020 21:25:55 -0700 Subject: [PATCH] Endpoint for downloading meta.ini data --- .../Controllers/IndexedFiles.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Wabbajack.BuildServer/Controllers/IndexedFiles.cs b/Wabbajack.BuildServer/Controllers/IndexedFiles.cs index c7d18aa1..820c4588 100644 --- a/Wabbajack.BuildServer/Controllers/IndexedFiles.cs +++ b/Wabbajack.BuildServer/Controllers/IndexedFiles.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using MongoDB.Bson; using MongoDB.Driver; +using MongoDB.Driver.Linq; using Wabbajack.BuildServer.Models; using Wabbajack.Common; using Wabbajack.VirtualFileSystem; @@ -18,6 +19,23 @@ namespace Wabbajack.BuildServer.Controllers { } + [HttpGet] + [Route("/{xxHashAsBase64}/meta.ini")] + public async Task GetFileMeta(string xxHashAsBase64) + { + var id = xxHashAsBase64.FromHex().ToBase64(); + var state = await Db.DownloadStates.AsQueryable() + .Where(d => d.Hash == id && d.IsValid) + .OrderByDescending(d => d.LastValidationTime) + .Take(1) + .ToListAsync(); + + if (state.Count == 0) + return NotFound(); + Response.ContentType = "text/plain"; + return Ok(string.Join("\r\n", state.FirstOrDefault().State.GetMetaIni())); + } + [HttpGet] [Route("{xxHashAsBase64}")] public async Task GetFile(string xxHashAsBase64)