|
|
@ -16,6 +16,9 @@ namespace MediaBrowser.Controller.Providers
|
|
|
|
private readonly ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>> _cache =
|
|
|
|
private readonly ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>> _cache =
|
|
|
|
new ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
new ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ConcurrentDictionary<string, FileSystemMetadata> _fileCache =
|
|
|
|
|
|
|
|
new ConcurrentDictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
|
|
public DirectoryService(ILogger logger, IFileSystem fileSystem)
|
|
|
|
public DirectoryService(ILogger logger, IFileSystem fileSystem)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
_logger = logger;
|
|
|
@ -100,29 +103,19 @@ namespace MediaBrowser.Controller.Providers
|
|
|
|
|
|
|
|
|
|
|
|
public FileSystemMetadata GetFile(string path)
|
|
|
|
public FileSystemMetadata GetFile(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _fileSystem.GetFileInfo(path);
|
|
|
|
FileSystemMetadata file;
|
|
|
|
//var directory = Path.GetDirectoryName(path);
|
|
|
|
if (!_fileCache.TryGetValue(path, out file))
|
|
|
|
|
|
|
|
{
|
|
|
|
//if (string.IsNullOrWhiteSpace(directory))
|
|
|
|
file = _fileSystem.GetFileInfo(path);
|
|
|
|
//{
|
|
|
|
|
|
|
|
// _logger.Debug("Parent path is null for {0}", path);
|
|
|
|
if (file != null)
|
|
|
|
// return null;
|
|
|
|
{
|
|
|
|
//}
|
|
|
|
_fileCache.TryAdd(path, file);
|
|
|
|
|
|
|
|
}
|
|
|
|
//try
|
|
|
|
}
|
|
|
|
//{
|
|
|
|
|
|
|
|
// var dict = GetFileSystemDictionary(directory, false);
|
|
|
|
return file;
|
|
|
|
|
|
|
|
//return _fileSystem.GetFileInfo(path);
|
|
|
|
// FileSystemMetadata entry;
|
|
|
|
|
|
|
|
// dict.TryGetValue(path, out entry);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// return entry;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//catch (Exception ex)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// _logger.ErrorException("Error in GetFileSystemDictionary. Directory: :{0}. Original path: {1}", ex, directory, path);
|
|
|
|
|
|
|
|
// return null;
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
|
|
|
|
public IEnumerable<FileSystemMetadata> GetDirectories(string path)
|
|
|
|