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
@ -74,6 +74,8 @@ namespace Wabbajack.CacheServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string HandleCacheCall(dynamic arg)
|
private string HandleCacheCall(dynamic arg)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string param = (string)arg.request;
|
string param = (string)arg.request;
|
||||||
var url = new Uri(Encoding.UTF8.GetString(param.FromHex()));
|
var url = new Uri(Encoding.UTF8.GetString(param.FromHex()));
|
||||||
@ -83,16 +85,27 @@ namespace Wabbajack.CacheServer
|
|||||||
{
|
{
|
||||||
Utils.Log($"{DateTime.Now} - Not Cached - {url}");
|
Utils.Log($"{DateTime.Now} - Not Cached - {url}");
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
var builder = new UriBuilder(url) {Host = "localhost", Port = Request.Url.Port ?? 80};
|
var builder = new UriBuilder(url) {Host = "localhost", Port = Request.Url.Port ?? 8080, Scheme = "http"};
|
||||||
client.DefaultRequestHeaders.Add("apikey", Request.Headers["apikey"]);
|
client.DefaultRequestHeaders.Add("apikey", Request.Headers["apikey"]);
|
||||||
client.GetStringSync(builder.Uri.ToString());
|
client.GetStringSync(builder.Uri.ToString());
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
Utils.Log($"Still not cached : {path}");
|
||||||
throw new InvalidDataException("Invalid Data");
|
throw new InvalidDataException("Invalid Data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils.Log($"Is Now Cached : {path}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Utils.Log($"{DateTime.Now} - From Cached - {url}");
|
Utils.Log($"{DateTime.Now} - From Cached - {url}");
|
||||||
return File.ReadAllText(path);
|
return File.ReadAllText(path);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.Log(ex.ToString());
|
||||||
|
return "ERROR";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,14 @@ namespace Wabbajack.Common
|
|||||||
Witcher3
|
Witcher3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class GameExtentions
|
||||||
|
{
|
||||||
|
public static GameMetaData MetaData(this Game game)
|
||||||
|
{
|
||||||
|
return GameRegistry.Games[game];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class GameMetaData
|
public class GameMetaData
|
||||||
{
|
{
|
||||||
public ModManager SupportedModManager { get; internal set; }
|
public ModManager SupportedModManager { get; internal set; }
|
||||||
|
@ -303,7 +303,7 @@ namespace Wabbajack.Lib.NexusApi
|
|||||||
|
|
||||||
public ModInfo GetModInfo(Game game, string modId)
|
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);
|
return GetCached<ModInfo>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user