diff --git a/Wabbajack.Server/Controllers/NexusCache.cs b/Wabbajack.Server/Controllers/NexusCache.cs index c1320fc3..b5ed0414 100644 --- a/Wabbajack.Server/Controllers/NexusCache.cs +++ b/Wabbajack.Server/Controllers/NexusCache.cs @@ -54,7 +54,7 @@ namespace Wabbajack.BuildServer.Controllers { var api = await NexusApiClient.Get(Request.Headers["apikey"].FirstOrDefault()); result = await api.GetModInfo(game, ModId, false); - await _sql.AddNexusModInfo(game, ModId, DateTime.UtcNow, result); + await _sql.AddNexusModInfo(game, ModId, result.updated_time, result); method = "NOT_CACHED"; @@ -82,7 +82,9 @@ namespace Wabbajack.BuildServer.Controllers { var api = await NexusApiClient.Get(Request.Headers["apikey"].FirstOrDefault()); result = await api.GetModFiles(game, ModId, false); - await _sql.AddNexusModFiles(game, ModId, DateTime.UtcNow, result); + var date = result.files.Select(f => f.uploaded_time).OrderByDescending(o => o).FirstOrDefault(); + date = date == default ? DateTime.UtcNow : date; + await _sql.AddNexusModFiles(game, ModId, date, result); method = "NOT_CACHED"; Interlocked.Increment(ref ForwardCount); diff --git a/Wabbajack.Server/DataLayer/Mappers.cs b/Wabbajack.Server/DataLayer/Mappers.cs index 0de6dc9b..95312b18 100644 --- a/Wabbajack.Server/DataLayer/Mappers.cs +++ b/Wabbajack.Server/DataLayer/Mappers.cs @@ -17,6 +17,23 @@ namespace Wabbajack.Server.DataLayer SqlMapper.AddTypeHandler(new JsonMapper()); SqlMapper.AddTypeHandler(new VersionMapper()); SqlMapper.AddTypeHandler(new GameMapper()); + SqlMapper.AddTypeHandler(new DateTimeHandler()); + } + + /// + /// Needed to make sure dates are all in UTC format + /// + private class DateTimeHandler : SqlMapper.TypeHandler + { + public override void SetValue(IDbDataParameter parameter, DateTime value) + { + parameter.Value = value; + } + + public override DateTime Parse(object value) + { + return DateTime.SpecifyKind((DateTime)value, DateTimeKind.Utc); + } } class JsonMapper : SqlMapper.TypeHandler