diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-10-01 20:28:16 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-10-01 20:28:16 -0400 |
| commit | 0690b4f2e09608b9f25ebb8ef9a325b57135e529 (patch) | |
| tree | 051661ff804a5a5f58402e534df96b5ea59c7a93 /MediaBrowser.Server.Implementations/Channels/ChannelManager.cs | |
| parent | 4aa959c1e266442804b6961aeb2d09f4b812f744 (diff) | |
Add user cinema mode setting
Diffstat (limited to 'MediaBrowser.Server.Implementations/Channels/ChannelManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Channels/ChannelManager.cs | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index d3b5fc0c3..8fb6bb434 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -869,7 +869,56 @@ namespace MediaBrowser.Server.Implementations.Channels private async Task<ChannelItemResult> GetAllItems(IIndexableChannel indexable, IChannel channel, InternalAllChannelMediaQuery query, CancellationToken cancellationToken) { - return await indexable.GetAllMedia(query, cancellationToken).ConfigureAwait(false); + var cacheLength = CacheLength; + var folderId = _jsonSerializer.SerializeToString(query).GetMD5().ToString("N"); + var cachePath = GetChannelDataCachePath(channel, query.UserId, folderId, null, false); + + try + { + if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow) + { + return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath); + } + } + catch (FileNotFoundException) + { + + } + catch (DirectoryNotFoundException) + { + + } + + await _resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); + + try + { + try + { + if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow) + { + return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath); + } + } + catch (FileNotFoundException) + { + + } + catch (DirectoryNotFoundException) + { + + } + + var result = await indexable.GetAllMedia(query, cancellationToken).ConfigureAwait(false); + + CacheResponse(result, cachePath); + + return result; + } + finally + { + _resourcePool.Release(); + } } public async Task<QueryResult<BaseItem>> GetChannelItemsInternal(ChannelItemQuery query, IProgress<double> progress, CancellationToken cancellationToken) |
