diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations')
| -rw-r--r-- | MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs (renamed from MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs) | 35 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj | 2 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs | 2 |
4 files changed, 23 insertions, 20 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs index 5aa01c706..e44b0c6af 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriterFunc.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/AsyncStreamWriter.cs @@ -4,38 +4,41 @@ using System.IO; using System.Threading.Tasks; using ServiceStack; using ServiceStack.Web; +using MediaBrowser.Controller.Net; namespace MediaBrowser.Server.Implementations.HttpServer { - public class AsyncStreamWriterFunc : IStreamWriter, IAsyncStreamWriter, IHasOptions + public class AsyncStreamWriter : IStreamWriter, IAsyncStreamWriter, IHasOptions { /// <summary> /// Gets or sets the source stream. /// </summary> /// <value>The source stream.</value> - private Func<Stream, Task> Writer { get; set; } - - /// <summary> - /// Gets the options. - /// </summary> - /// <value>The options.</value> - public IDictionary<string, string> Options { get; private set; } + private IAsyncStreamSource _source; public Action OnComplete { get; set; } public Action OnError { get; set; } /// <summary> - /// Initializes a new instance of the <see cref="StreamWriter" /> class. + /// Initializes a new instance of the <see cref="AsyncStreamWriter" /> class. /// </summary> - public AsyncStreamWriterFunc(Func<Stream, Task> writer, IDictionary<string, string> headers) + public AsyncStreamWriter(IAsyncStreamSource source) { - Writer = writer; + _source = source; + } - if (headers == null) + public IDictionary<string, string> Options + { + get { - headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + var hasOptions = _source as IHasOptions; + if (hasOptions != null) + { + return hasOptions.Options; + } + + return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); } - Options = headers; } /// <summary> @@ -44,13 +47,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// <param name="responseStream">The response stream.</param> public void WriteTo(Stream responseStream) { - var task = Writer(responseStream); + var task = _source.WriteToAsync(responseStream); Task.WaitAll(task); } public async Task WriteToAsync(Stream responseStream) { - await Writer(responseStream).ConfigureAwait(false); + await _source.WriteToAsync(responseStream).ConfigureAwait(false); } } } diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index 27065d0f5..c55e98388 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -704,9 +704,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw error; } - public object GetAsyncStreamWriter(Func<Stream, Task> streamWriter, IDictionary<string, string> responseHeaders = null) + public object GetAsyncStreamWriter(IAsyncStreamSource streamSource) { - return new AsyncStreamWriterFunc(streamWriter, responseHeaders); + return new AsyncStreamWriter(streamSource); } } }
\ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 52723688f..442465430 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -156,7 +156,7 @@ <Compile Include="EntryPoints\ServerEventNotifier.cs" /> <Compile Include="EntryPoints\UserDataChangeNotifier.cs" /> <Compile Include="FileOrganization\OrganizerScheduledTask.cs" /> - <Compile Include="HttpServer\AsyncStreamWriterFunc.cs" /> + <Compile Include="HttpServer\AsyncStreamWriter.cs" /> <Compile Include="HttpServer\IHttpListener.cs" /> <Compile Include="HttpServer\Security\AuthorizationContext.cs" /> <Compile Include="HttpServer\ContainerAdapter.cs" /> diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 0e36ede7a..cf8e2fe36 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -2152,7 +2152,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { if (query.User != null) { - query.SortBy = new[] { ItemSortBy.IsPlayed, "SimilarityScore", ItemSortBy.Random }; + query.SortBy = new[] { "SimilarityScore", ItemSortBy.Random }; } else { |
