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 File.GetLastWriteTime(await GetImagePath().ConfigureAwait(false));
|
||||
return File.GetLastWriteTimeUtc(await GetImagePath().ConfigureAwait(false));
|
||||
}
|
||||
|
||||
private int? Height
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net.Handlers;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
|
||||
|
@ -9,13 +10,39 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
{
|
||||
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()
|
||||
{
|
||||
string name = QueryString["assemblyfilename"];
|
||||
|
||||
BasePluginConfiguration config = Kernel.Instance.Plugins.First(p => p.AssemblyFileName.Equals(name, StringComparison.OrdinalIgnoreCase)).Configuration;
|
||||
|
||||
return Task.FromResult<BasePluginConfiguration>(config);
|
||||
return Task.FromResult<BasePluginConfiguration>(Plugin.Configuration);
|
||||
}
|
||||
|
||||
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.Controller;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
|
@ -11,5 +13,18 @@ namespace MediaBrowser.Api.HttpHandlers
|
|||
{
|
||||
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;
|
||||
|
||||
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])));
|
||||
|
||||
ctx.Response.AddHeader("Access-Control-Allow-Origin", "*");
|
||||
|
@ -195,10 +196,10 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||
{
|
||||
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 (IsCacheValid(ifModifiedSince, cacheDuration, lastDateModified))
|
||||
if (IsCacheValid(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified))
|
||||
{
|
||||
StatusCode = 304;
|
||||
}
|
||||
|
@ -207,6 +208,8 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||
|
||||
await PrepareResponse().ConfigureAwait(false);
|
||||
|
||||
Logger.LogInfo("Responding with status code {0} for url {1}", StatusCode, url);
|
||||
|
||||
if (IsResponseValid)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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.Expires] = DateTime.Now.Add(duration).ToString("r");
|
||||
response.Headers[HttpResponseHeader.Expires] = now.Add(duration).ToString("r");
|
||||
response.Headers[HttpResponseHeader.LastModified] = lastModified.ToString("r");
|
||||
}
|
||||
|
||||
|
@ -334,7 +339,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||
|
||||
DateTime cacheExpirationDate = ifModifiedSince.Add(cacheDuration);
|
||||
|
||||
if (DateTime.Now < cacheExpirationDate)
|
||||
if (DateTime.UtcNow < cacheExpirationDate)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -347,7 +352,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||
/// </summary>
|
||||
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()
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||
|
||||
if (SourceStream != null)
|
||||
{
|
||||
value = File.GetLastWriteTime(Path);
|
||||
value = File.GetLastWriteTimeUtc(Path);
|
||||
}
|
||||
|
||||
return Task.FromResult<DateTime?>(value);
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace MediaBrowser.Common.Plugins
|
|||
{
|
||||
if (File.Exists(ConfigurationFilePath))
|
||||
{
|
||||
_ConfigurationDateLastModified = File.GetLastWriteTime(ConfigurationFilePath);
|
||||
_ConfigurationDateLastModified = File.GetLastWriteTimeUtc(ConfigurationFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ namespace MediaBrowser.Common.UI
|
|||
|
||||
try
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
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();
|
||||
|
||||
this.ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace MediaBrowser.Controller.IO
|
|||
}
|
||||
}
|
||||
|
||||
public DateTime CreationTime
|
||||
public DateTime CreationTimeUtc
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -196,7 +196,7 @@ namespace MediaBrowser.Controller.IO
|
|||
}
|
||||
}
|
||||
|
||||
public DateTime LastAccessTime
|
||||
public DateTime LastAccessTimeUtc
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ namespace MediaBrowser.Controller.IO
|
|||
}
|
||||
}
|
||||
|
||||
public DateTime LastWriteTime
|
||||
public DateTime LastWriteTimeUtc
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -216,7 +216,7 @@ namespace MediaBrowser.Controller.IO
|
|||
{
|
||||
long highBits = filetime.dwHighDateTime;
|
||||
highBits = highBits << 32;
|
||||
return DateTime.FromFileTime(highBits + (long)filetime.dwLowDateTime);
|
||||
return DateTime.FromFileTimeUtc(highBits + (long)filetime.dwLowDateTime);
|
||||
}
|
||||
|
||||
public string Path { get; set; }
|
||||
|
|
|
@ -268,8 +268,8 @@ namespace MediaBrowser.Controller.Library
|
|||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
item.DateCreated = Directory.GetCreationTime(path);
|
||||
item.DateModified = Directory.GetLastAccessTime(path);
|
||||
item.DateCreated = Directory.GetCreationTimeUtc(path);
|
||||
item.DateModified = Directory.GetLastWriteTimeUtc(path);
|
||||
|
||||
ItemResolveEventArgs args = new ItemResolveEventArgs();
|
||||
args.FileInfo = FileData.GetFileData(path);
|
||||
|
|
|
@ -276,7 +276,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
|
||||
if (DateTime.TryParse(val, out i))
|
||||
{
|
||||
return i;
|
||||
return i.ToUniversalTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,20 +88,20 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
|
||||
if (childData != null)
|
||||
{
|
||||
item.DateCreated = childData.Value.CreationTime;
|
||||
item.DateModified = childData.Value.LastWriteTime;
|
||||
item.DateCreated = childData.Value.CreationTimeUtc;
|
||||
item.DateModified = childData.Value.LastWriteTimeUtc;
|
||||
}
|
||||
else
|
||||
{
|
||||
WIN32_FIND_DATA fileData = FileData.GetFileData(item.Path);
|
||||
item.DateCreated = fileData.CreationTime;
|
||||
item.DateModified = fileData.LastWriteTime;
|
||||
item.DateCreated = fileData.CreationTimeUtc;
|
||||
item.DateModified = fileData.LastWriteTimeUtc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item.DateCreated = args.FileInfo.CreationTime;
|
||||
item.DateModified = args.FileInfo.LastWriteTime;
|
||||
item.DateCreated = args.FileInfo.CreationTimeUtc;
|
||||
item.DateModified = args.FileInfo.LastWriteTimeUtc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace MediaBrowser.Controller.Xml
|
|||
DateTime added;
|
||||
if (DateTime.TryParse(reader.ReadElementContentAsString() ?? string.Empty, out added))
|
||||
{
|
||||
item.DateCreated = added;
|
||||
item.DateCreated = added.ToUniversalTime();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -232,7 +232,7 @@ namespace MediaBrowser.Controller.Xml
|
|||
|
||||
if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
|
||||
{
|
||||
item.PremiereDate = airDate;
|
||||
item.PremiereDate = airDate.ToUniversalTime();
|
||||
item.ProductionYear = airDate.Year;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace MediaBrowser.Model.Entities
|
|||
/// </summary>
|
||||
public bool IsRecentlyAdded(User user)
|
||||
{
|
||||
return (DateTime.Now - DateCreated).TotalDays < user.RecentItemDays;
|
||||
return (DateTime.UtcNow - DateCreated).TotalDays < user.RecentItemDays;
|
||||
}
|
||||
|
||||
public void AddPerson(PersonInfo person)
|
||||
|
|
Loading…
Reference in New Issue
Block a user