mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 22:07:13 -04:00
add file cache
This commit is contained in:
parent
7835d3d629
commit
894d87fabb
@ -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))
|
||||||
|
{
|
||||||
|
file = _fileSystem.GetFileInfo(path);
|
||||||
|
|
||||||
//if (string.IsNullOrWhiteSpace(directory))
|
if (file != null)
|
||||||
//{
|
{
|
||||||
// _logger.Debug("Parent path is null for {0}", path);
|
_fileCache.TryAdd(path, file);
|
||||||
// return null;
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//try
|
return file;
|
||||||
//{
|
//return _fileSystem.GetFileInfo(path);
|
||||||
// var dict = GetFileSystemDictionary(directory, false);
|
|
||||||
|
|
||||||
// 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)
|
||||||
|
@ -349,9 +349,6 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
|
|
||||||
if (!runAllProviders)
|
if (!runAllProviders)
|
||||||
{
|
{
|
||||||
// Avoid implicitly captured closure
|
|
||||||
var currentItem = item;
|
|
||||||
|
|
||||||
var providersWithChanges = providers
|
var providersWithChanges = providers
|
||||||
.Where(i =>
|
.Where(i =>
|
||||||
{
|
{
|
||||||
@ -361,12 +358,6 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
return HasChanged(item, hasFileChangeMonitor, options.DirectoryService);
|
return HasChanged(item, hasFileChangeMonitor, options.DirectoryService);
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasChangeMonitor = i as IHasChangeMonitor;
|
|
||||||
if (hasChangeMonitor != null)
|
|
||||||
{
|
|
||||||
return HasChanged(item, hasChangeMonitor, currentItem.DateLastSaved, options.DirectoryService);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -726,27 +717,6 @@ namespace MediaBrowser.Providers.Manager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasChanged(IHasMetadata item, IHasChangeMonitor changeMonitor, DateTime date, IDirectoryService directoryService)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var hasChanged = changeMonitor.HasChanged(item, directoryService, date);
|
|
||||||
|
|
||||||
//if (hasChanged)
|
|
||||||
//{
|
|
||||||
// Logger.Debug("{0} reports change to {1} since {2}", changeMonitor.GetType().Name,
|
|
||||||
// item.Path ?? item.Name, date);
|
|
||||||
//}
|
|
||||||
|
|
||||||
return hasChanged;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.ErrorException("Error in {0}.HasChanged", ex, changeMonitor.GetType().Name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RefreshResult
|
public class RefreshResult
|
||||||
|
Loading…
Reference in New Issue
Block a user