mirror of https://github.com/jellyfin/jellyfin.git
Switched date operations to utc
This commit is contained in:
parent
f931a375cf
commit
4752d12aaa
|
@ -136,7 +136,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return File.GetLastWriteTime(await GetImagePath().ConfigureAwait(false));
|
return File.GetLastWriteTimeUtc(await GetImagePath().ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int? Height
|
private int? Height
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Net.Handlers;
|
using MediaBrowser.Common.Net.Handlers;
|
||||||
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
|
|
||||||
|
@ -9,13 +10,39 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
|
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
|
||||||
{
|
{
|
||||||
|
private BasePlugin _Plugin = null;
|
||||||
|
private BasePlugin Plugin
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_Plugin == null)
|
||||||
|
{
|
||||||
|
string name = QueryString["assemblyfilename"];
|
||||||
|
|
||||||
|
_Plugin = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _Plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
|
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
string name = QueryString["assemblyfilename"];
|
return Task.FromResult<BasePluginConfiguration>(Plugin.Configuration);
|
||||||
|
|
||||||
BasePluginConfiguration config = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase)).Configuration;
|
|
||||||
|
|
||||||
return Task.FromResult<BasePluginConfiguration>(config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override TimeSpan CacheDuration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return TimeSpan.FromDays(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Task<DateTime?> GetLastDateModified()
|
||||||
|
{
|
||||||
|
return Task.FromResult<DateTime?>(Plugin.ConfigurationDateLastModified);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Threading.Tasks;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Net.Handlers;
|
using MediaBrowser.Common.Net.Handlers;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
@ -11,5 +13,18 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
return Task.FromResult<ServerConfiguration>(Kernel.Instance.Configuration);
|
return Task.FromResult<ServerConfiguration>(Kernel.Instance.Configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override TimeSpan CacheDuration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return TimeSpan.FromDays(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Task<DateTime?> GetLastDateModified()
|
||||||
|
{
|
||||||
|
return Task.FromResult<DateTime?>(File.GetLastWriteTimeUtc(Kernel.Instance.ApplicationPaths.SystemConfigurationFilePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,8 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
{
|
{
|
||||||
HttpListenerContext = ctx;
|
HttpListenerContext = ctx;
|
||||||
|
|
||||||
Logger.LogInfo("Http Server received request at: " + ctx.Request.Url.ToString());
|
string url = ctx.Request.Url.ToString();
|
||||||
|
Logger.LogInfo("Http Server received request at: " + url);
|
||||||
Logger.LogInfo("Http Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));
|
Logger.LogInfo("Http Headers: " + string.Join(",", ctx.Request.Headers.AllKeys.Select(k => k + "=" + ctx.Request.Headers[k])));
|
||||||
|
|
||||||
ctx.Response.AddHeader("Access-Control-Allow-Origin", "*");
|
ctx.Response.AddHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
@ -195,10 +196,10 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
{
|
{
|
||||||
DateTime ifModifiedSince;
|
DateTime ifModifiedSince;
|
||||||
|
|
||||||
if (DateTime.TryParse(ctx.Request.Headers["If-Modified-Since"].Replace(" GMT", string.Empty), out ifModifiedSince))
|
if (DateTime.TryParse(ctx.Request.Headers["If-Modified-Since"], out ifModifiedSince))
|
||||||
{
|
{
|
||||||
// If the cache hasn't expired yet just return a 304
|
// If the cache hasn't expired yet just return a 304
|
||||||
if (IsCacheValid(ifModifiedSince, cacheDuration, lastDateModified))
|
if (IsCacheValid(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified))
|
||||||
{
|
{
|
||||||
StatusCode = 304;
|
StatusCode = 304;
|
||||||
}
|
}
|
||||||
|
@ -207,6 +208,8 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
|
|
||||||
await PrepareResponse().ConfigureAwait(false);
|
await PrepareResponse().ConfigureAwait(false);
|
||||||
|
|
||||||
|
Logger.LogInfo("Responding with status code {0} for url {1}", StatusCode, url);
|
||||||
|
|
||||||
if (IsResponseValid)
|
if (IsResponseValid)
|
||||||
{
|
{
|
||||||
bool compressResponse = ShouldCompressResponse(ctx.Response.ContentType) && ClientSupportsCompression;
|
bool compressResponse = ShouldCompressResponse(ctx.Response.ContentType) && ClientSupportsCompression;
|
||||||
|
@ -295,10 +298,12 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
|
|
||||||
private void CacheResponse(HttpListenerResponse response, TimeSpan duration, DateTime? dateModified)
|
private void CacheResponse(HttpListenerResponse response, TimeSpan duration, DateTime? dateModified)
|
||||||
{
|
{
|
||||||
DateTime lastModified = dateModified ?? DateTime.Now;
|
DateTime now = DateTime.UtcNow;
|
||||||
|
|
||||||
|
DateTime lastModified = dateModified ?? now;
|
||||||
|
|
||||||
response.Headers[HttpResponseHeader.CacheControl] = "public, max-age=" + Convert.ToInt32(duration.TotalSeconds);
|
response.Headers[HttpResponseHeader.CacheControl] = "public, max-age=" + Convert.ToInt32(duration.TotalSeconds);
|
||||||
response.Headers[HttpResponseHeader.Expires] = DateTime.Now.Add(duration).ToString("r");
|
response.Headers[HttpResponseHeader.Expires] = now.Add(duration).ToString("r");
|
||||||
response.Headers[HttpResponseHeader.LastModified] = lastModified.ToString("r");
|
response.Headers[HttpResponseHeader.LastModified] = lastModified.ToString("r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +339,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
|
|
||||||
DateTime cacheExpirationDate = ifModifiedSince.Add(cacheDuration);
|
DateTime cacheExpirationDate = ifModifiedSince.Add(cacheDuration);
|
||||||
|
|
||||||
if (DateTime.Now < cacheExpirationDate)
|
if (DateTime.UtcNow < cacheExpirationDate)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +352,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DateTime NormalizeDateForComparison(DateTime date)
|
private DateTime NormalizeDateForComparison(DateTime date)
|
||||||
{
|
{
|
||||||
return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second);
|
return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual long? GetTotalContentLength()
|
protected virtual long? GetTotalContentLength()
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
|
|
||||||
if (SourceStream != null)
|
if (SourceStream != null)
|
||||||
{
|
{
|
||||||
value = File.GetLastWriteTime(Path);
|
value = File.GetLastWriteTimeUtc(Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.FromResult<DateTime?>(value);
|
return Task.FromResult<DateTime?>(value);
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace MediaBrowser.Common.Plugins
|
||||||
{
|
{
|
||||||
if (File.Exists(ConfigurationFilePath))
|
if (File.Exists(ConfigurationFilePath))
|
||||||
{
|
{
|
||||||
_ConfigurationDateLastModified = File.GetLastWriteTime(ConfigurationFilePath);
|
_ConfigurationDateLastModified = File.GetLastWriteTimeUtc(ConfigurationFilePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@ namespace MediaBrowser.Common.UI
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.UtcNow;
|
||||||
|
|
||||||
await Kernel.Init(progress);
|
await Kernel.Init(progress);
|
||||||
|
|
||||||
Logger.LogInfo("Kernel.Init completed in {0} seconds.", (DateTime.Now - now).TotalSeconds);
|
Logger.LogInfo("Kernel.Init completed in {0} seconds.", (DateTime.UtcNow - now).TotalSeconds);
|
||||||
splash.Close();
|
splash.Close();
|
||||||
|
|
||||||
this.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
|
this.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
|
||||||
|
|
|
@ -188,7 +188,7 @@ namespace MediaBrowser.Controller.IO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime CreationTime
|
public DateTime CreationTimeUtc
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -196,7 +196,7 @@ namespace MediaBrowser.Controller.IO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime LastAccessTime
|
public DateTime LastAccessTimeUtc
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.IO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime LastWriteTime
|
public DateTime LastWriteTimeUtc
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -216,7 +216,7 @@ namespace MediaBrowser.Controller.IO
|
||||||
{
|
{
|
||||||
long highBits = filetime.dwHighDateTime;
|
long highBits = filetime.dwHighDateTime;
|
||||||
highBits = highBits << 32;
|
highBits = highBits << 32;
|
||||||
return DateTime.FromFileTime(highBits + (long)filetime.dwLowDateTime);
|
return DateTime.FromFileTimeUtc(highBits + (long)filetime.dwLowDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
|
@ -268,8 +268,8 @@ namespace MediaBrowser.Controller.Library
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
item.DateCreated = Directory.GetCreationTime(path);
|
item.DateCreated = Directory.GetCreationTimeUtc(path);
|
||||||
item.DateModified = Directory.GetLastAccessTime(path);
|
item.DateModified = Directory.GetLastWriteTimeUtc(path);
|
||||||
|
|
||||||
ItemResolveEventArgs args = new ItemResolveEventArgs();
|
ItemResolveEventArgs args = new ItemResolveEventArgs();
|
||||||
args.FileInfo = FileData.GetFileData(path);
|
args.FileInfo = FileData.GetFileData(path);
|
||||||
|
|
|
@ -276,7 +276,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
|
|
||||||
if (DateTime.TryParse(val, out i))
|
if (DateTime.TryParse(val, out i))
|
||||||
{
|
{
|
||||||
return i;
|
return i.ToUniversalTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,20 +88,20 @@ namespace MediaBrowser.Controller.Resolvers
|
||||||
|
|
||||||
if (childData != null)
|
if (childData != null)
|
||||||
{
|
{
|
||||||
item.DateCreated = childData.Value.CreationTime;
|
item.DateCreated = childData.Value.CreationTimeUtc;
|
||||||
item.DateModified = childData.Value.LastWriteTime;
|
item.DateModified = childData.Value.LastWriteTimeUtc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA fileData = FileData.GetFileData(item.Path);
|
WIN32_FIND_DATA fileData = FileData.GetFileData(item.Path);
|
||||||
item.DateCreated = fileData.CreationTime;
|
item.DateCreated = fileData.CreationTimeUtc;
|
||||||
item.DateModified = fileData.LastWriteTime;
|
item.DateModified = fileData.LastWriteTimeUtc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item.DateCreated = args.FileInfo.CreationTime;
|
item.DateCreated = args.FileInfo.CreationTimeUtc;
|
||||||
item.DateModified = args.FileInfo.LastWriteTime;
|
item.DateModified = args.FileInfo.LastWriteTimeUtc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace MediaBrowser.Controller.Xml
|
||||||
DateTime added;
|
DateTime added;
|
||||||
if (DateTime.TryParse(reader.ReadElementContentAsString() ?? string.Empty, out added))
|
if (DateTime.TryParse(reader.ReadElementContentAsString() ?? string.Empty, out added))
|
||||||
{
|
{
|
||||||
item.DateCreated = added;
|
item.DateCreated = added.ToUniversalTime();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ namespace MediaBrowser.Controller.Xml
|
||||||
|
|
||||||
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
|
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
|
||||||
{
|
{
|
||||||
item.PremiereDate = airDate;
|
item.PremiereDate = airDate.ToUniversalTime();
|
||||||
item.ProductionYear = airDate.Year;
|
item.ProductionYear = airDate.Year;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace MediaBrowser.Model.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRecentlyAdded(User user)
|
public bool IsRecentlyAdded(User user)
|
||||||
{
|
{
|
||||||
return (DateTime.Now - DateCreated).TotalDays < user.RecentItemDays;
|
return (DateTime.UtcNow - DateCreated).TotalDays < user.RecentItemDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddPerson(PersonInfo person)
|
public void AddPerson(PersonInfo person)
|
||||||
|
|
Loading…
Reference in New Issue