mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Added extensions to the game enum, fixed the cache server (again)
This commit is contained in:
parent
29f829329f
commit
d636d06ced
@ -75,24 +75,37 @@ namespace Wabbajack.CacheServer
|
||||
|
||||
private string HandleCacheCall(dynamic arg)
|
||||
{
|
||||
string param = (string)arg.request;
|
||||
var url = new Uri(Encoding.UTF8.GetString(param.FromHex()));
|
||||
var path = Path.Combine(NexusApiClient.LocalCacheDir, arg.request + ".json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
try
|
||||
{
|
||||
Utils.Log($"{DateTime.Now} - Not Cached - {url}");
|
||||
var client = new HttpClient();
|
||||
var builder = new UriBuilder(url) {Host = "localhost", Port = Request.Url.Port ?? 80};
|
||||
client.DefaultRequestHeaders.Add("apikey", Request.Headers["apikey"]);
|
||||
client.GetStringSync(builder.Uri.ToString());
|
||||
string param = (string)arg.request;
|
||||
var url = new Uri(Encoding.UTF8.GetString(param.FromHex()));
|
||||
var path = Path.Combine(NexusApiClient.LocalCacheDir, arg.request + ".json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
throw new InvalidDataException("Invalid Data");
|
||||
{
|
||||
Utils.Log($"{DateTime.Now} - Not Cached - {url}");
|
||||
var client = new HttpClient();
|
||||
var builder = new UriBuilder(url) {Host = "localhost", Port = Request.Url.Port ?? 8080, Scheme = "http"};
|
||||
client.DefaultRequestHeaders.Add("apikey", Request.Headers["apikey"]);
|
||||
client.GetStringSync(builder.Uri.ToString());
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Utils.Log($"Still not cached : {path}");
|
||||
throw new InvalidDataException("Invalid Data");
|
||||
}
|
||||
|
||||
Utils.Log($"Is Now Cached : {path}");
|
||||
|
||||
}
|
||||
|
||||
Utils.Log($"{DateTime.Now} - From Cached - {url}");
|
||||
return File.ReadAllText(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.Log(ex.ToString());
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
Utils.Log($"{DateTime.Now} - From Cached - {url}");
|
||||
return File.ReadAllText(path);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,14 @@ namespace Wabbajack.Common
|
||||
Witcher3
|
||||
}
|
||||
|
||||
public static class GameExtentions
|
||||
{
|
||||
public static GameMetaData MetaData(this Game game)
|
||||
{
|
||||
return GameRegistry.Games[game];
|
||||
}
|
||||
}
|
||||
|
||||
public class GameMetaData
|
||||
{
|
||||
public ModManager SupportedModManager { get; internal set; }
|
||||
|
@ -303,7 +303,7 @@ namespace Wabbajack.Lib.NexusApi
|
||||
|
||||
public ModInfo GetModInfo(Game game, string modId)
|
||||
{
|
||||
var url = $"https://api.nexusmods.com/v1/games/{GameRegistry.Games[game].NexusName}/mods/{modId}.json";
|
||||
var url = $"https://api.nexusmods.com/v1/games/{game.MetaData().NexusName}/mods/{modId}.json";
|
||||
return GetCached<ModInfo>(url);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user