fix folder caching
This commit is contained in:
parent
02a4b90f65
commit
ec111eebd3
|
@ -48,11 +48,11 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
{
|
{
|
||||||
var eofCount = 0;
|
var eofCount = 0;
|
||||||
|
|
||||||
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
|
using (var fs = _fileSystem.GetFileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
|
||||||
{
|
{
|
||||||
while (eofCount < 15)
|
while (eofCount < 15)
|
||||||
{
|
{
|
||||||
var bytesRead = await CopyToAsyncInternal(fs, outputStream, BufferSize, cancellationToken).ConfigureAwait(false);
|
var bytesRead = await CopyToAsyncInternal(fs, outputStream, BufferSize, _cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
//var position = fs.Position;
|
//var position = fs.Position;
|
||||||
//_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
|
//_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
|
||||||
|
@ -63,7 +63,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||||
{
|
{
|
||||||
eofCount++;
|
eofCount++;
|
||||||
}
|
}
|
||||||
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
await Task.Delay(100, _cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,8 @@ using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetCachedChildren()
|
private void ClearCache()
|
||||||
{
|
{
|
||||||
lock (_childIdsLock)
|
lock (_childIdsLock)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +116,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public override bool BeforeMetadataRefresh()
|
public override bool BeforeMetadataRefresh()
|
||||||
{
|
{
|
||||||
ResetCachedChildren();
|
ClearCache();
|
||||||
|
|
||||||
var changed = base.BeforeMetadataRefresh() || _requiresRefresh;
|
var changed = base.BeforeMetadataRefresh() || _requiresRefresh;
|
||||||
_requiresRefresh = false;
|
_requiresRefresh = false;
|
||||||
|
@ -123,7 +125,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
|
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
|
||||||
{
|
{
|
||||||
ResetCachedChildren();
|
ClearCache();
|
||||||
|
|
||||||
var path = ContainingFolderPath;
|
var path = ContainingFolderPath;
|
||||||
|
|
||||||
|
@ -165,6 +167,16 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override async Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
ClearCache();
|
||||||
|
|
||||||
|
await base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
ClearCache();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the virtual child.
|
/// Adds the virtual child.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -180,15 +192,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
_virtualChildren.Add(child);
|
_virtualChildren.Add(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the children of this folder from the actual file system
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
|
||||||
protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
|
||||||
{
|
|
||||||
return base.GetNonCachedChildren(directoryService).Concat(_virtualChildren);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the virtual child.
|
/// Finds the virtual child.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetCachedChildren()
|
private void ClearCache()
|
||||||
{
|
{
|
||||||
lock (_childIdsLock)
|
lock (_childIdsLock)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public override bool BeforeMetadataRefresh()
|
public override bool BeforeMetadataRefresh()
|
||||||
{
|
{
|
||||||
ResetCachedChildren();
|
ClearCache();
|
||||||
|
|
||||||
var hasChanges = base.BeforeMetadataRefresh();
|
var hasChanges = base.BeforeMetadataRefresh();
|
||||||
|
|
||||||
|
@ -107,13 +107,22 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return hasChanges;
|
return hasChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
||||||
|
{
|
||||||
|
ClearCache();
|
||||||
|
|
||||||
|
return base.GetNonCachedChildren(directoryService);
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
|
protected override async Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
|
||||||
{
|
{
|
||||||
ResetCachedChildren();
|
ClearCache();
|
||||||
|
|
||||||
await base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService)
|
await base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
ClearCache();
|
||||||
|
|
||||||
// Not the best way to handle this, but it solves an issue
|
// Not the best way to handle this, but it solves an issue
|
||||||
// CollectionFolders aren't always getting saved after changes
|
// CollectionFolders aren't always getting saved after changes
|
||||||
// This means that grabbing the item by Id may end up returning the old one
|
// This means that grabbing the item by Id may end up returning the old one
|
||||||
|
|
|
@ -570,7 +570,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
playlistItem.MaxAudioChannels = Math.Min(options.MaxAudioChannels.Value, currentValue);
|
playlistItem.MaxAudioChannels = Math.Min(options.MaxAudioChannels.Value, currentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
int audioBitrate = GetAudioBitrate(options.GetMaxBitrate(), playlistItem.TargetAudioChannels, playlistItem.TargetAudioCodec, audioStream);
|
int audioBitrate = GetAudioBitrate(playlistItem.SubProtocol, options.GetMaxBitrate(), playlistItem.TargetAudioChannels, playlistItem.TargetAudioCodec, audioStream);
|
||||||
playlistItem.AudioBitrate = Math.Min(playlistItem.AudioBitrate ?? audioBitrate, audioBitrate);
|
playlistItem.AudioBitrate = Math.Min(playlistItem.AudioBitrate ?? audioBitrate, audioBitrate);
|
||||||
|
|
||||||
int? maxBitrateSetting = options.GetMaxBitrate();
|
int? maxBitrateSetting = options.GetMaxBitrate();
|
||||||
|
@ -593,7 +593,7 @@ namespace MediaBrowser.Model.Dlna
|
||||||
return playlistItem;
|
return playlistItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetAudioBitrate(int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
|
private int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream)
|
||||||
{
|
{
|
||||||
var defaultBitrate = 128000;
|
var defaultBitrate = 128000;
|
||||||
if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3"))
|
if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3"))
|
||||||
|
@ -611,7 +611,14 @@ namespace MediaBrowser.Model.Dlna
|
||||||
{
|
{
|
||||||
if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3"))
|
if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3"))
|
||||||
{
|
{
|
||||||
defaultBitrate = Math.Max(448000, defaultBitrate);
|
if (string.Equals(subProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
defaultBitrate = Math.Max(384000, defaultBitrate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
defaultBitrate = Math.Max(448000, defaultBitrate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2152,7 +2152,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
{
|
{
|
||||||
if (query.User != null)
|
if (query.User != null)
|
||||||
{
|
{
|
||||||
query.SortBy = new[] { ItemSortBy.IsPlayed, "SimilarityScore", ItemSortBy.Random };
|
query.SortBy = new[] { "SimilarityScore", ItemSortBy.Random };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user