From 74a8ca9c38d17e407c70aafe2cfd42b8b13d923e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 9 Oct 2014 18:22:04 -0400 Subject: fix case sensitive file names --- .../Library/MetadataConfigurationStore.cs | 29 ++++++++++++++++++++++ .../MediaBrowser.Controller.csproj | 1 + .../Resolvers/EntityResolutionHelper.cs | 20 ++++++++++++--- 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 MediaBrowser.Controller/Library/MetadataConfigurationStore.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Library/MetadataConfigurationStore.cs b/MediaBrowser.Controller/Library/MetadataConfigurationStore.cs new file mode 100644 index 0000000000..6fad786a26 --- /dev/null +++ b/MediaBrowser.Controller/Library/MetadataConfigurationStore.cs @@ -0,0 +1,29 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Configuration; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Library +{ + public class MetadataConfigurationStore : IConfigurationFactory + { + public IEnumerable GetConfigurations() + { + return new List + { + new ConfigurationStore + { + Key = "metadata", + ConfigurationType = typeof(MetadataConfiguration) + } + }; + } + } + + public static class MetadataConfigurationExtensions + { + public static MetadataConfiguration GetMetadataConfiguration(this IConfigurationManager config) + { + return config.GetConfiguration("metadata"); + } + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index e04cc20874..d966d4df56 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -174,6 +174,7 @@ + diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs index 4ddfa59790..7d9c9d8769 100644 --- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -211,7 +211,7 @@ namespace MediaBrowser.Controller.Resolvers { if (includeCreationTime) { - item.DateCreated = DateTime.UtcNow; + SetDateCreated(item, fileSystem, childData); } item.DateModified = fileSystem.GetLastWriteTimeUtc(childData); @@ -224,7 +224,7 @@ namespace MediaBrowser.Controller.Resolvers { if (includeCreationTime) { - item.DateCreated = DateTime.UtcNow; + SetDateCreated(item, fileSystem, fileData); } item.DateModified = fileSystem.GetLastWriteTimeUtc(fileData); } @@ -234,10 +234,24 @@ namespace MediaBrowser.Controller.Resolvers { if (includeCreationTime) { - item.DateCreated = DateTime.UtcNow; + SetDateCreated(item, fileSystem, args.FileInfo); } item.DateModified = fileSystem.GetLastWriteTimeUtc(args.FileInfo); } } + + private static void SetDateCreated(BaseItem item, IFileSystem fileSystem, FileSystemInfo info) + { + var config = BaseItem.ConfigurationManager.GetMetadataConfiguration(); + + if (config.UseFileCreationTimeForDateAdded) + { + item.DateModified = fileSystem.GetCreationTimeUtc(info); + } + else + { + item.DateCreated = DateTime.UtcNow; + } + } } } -- cgit v1.2.3