Fix bug in time conversion, implement update endpoint for nexus cache

This commit is contained in:
Timothy Baldridge 2019-11-21 17:41:01 -07:00
parent f7a36bf20e
commit 0ddcaa8241
3 changed files with 15 additions and 2 deletions

View File

@ -23,6 +23,14 @@ namespace Wabbajack.CacheServer
Get("/v1/games/{GameName}/mods/{ModID}.json", HandleModInfo);
Get("/nexus_api_cache/{request}.json", HandleCacheCall);
Get("/nexus_api_cache", ListCache);
Get("/nexus_api_cache/update", UpdateCache);
}
private object UpdateCache(object arg)
{
var api = new NexusApiClient(Request.Headers["apikey"].FirstOrDefault());
api.ClearUpdatedModsInCache();
return "Done";
}
private string ListCache(object arg)

View File

@ -211,7 +211,7 @@ namespace Wabbajack.Common
public static DateTime AsUnixTime(this long timestamp)
{
DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(timestamp).ToLocalTime();
dtDateTime = dtDateTime.AddSeconds(timestamp);
return dtDateTime;
}

View File

@ -398,7 +398,12 @@ namespace Wabbajack.Lib.NexusApi
.ToList();
Utils.Log($"Purging {to_purge.Count} cache entries");
to_purge.PMap(queue, f => File.Delete(f.f));
to_purge.PMap(queue, f =>
{
var uri = new Uri(Encoding.UTF8.GetString(Path.GetFileNameWithoutExtension(f.f).FromHex()));
Utils.Log($"Purging {uri}");
File.Delete(f.f);
});
}
}