aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/AggregateFolder.cs32
-rw-r--r--MediaBrowser.Controller/Entities/UserRootFolder.cs15
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
-rw-r--r--MediaBrowser.Controller/Net/IAsyncStreamSource.cs18
-rw-r--r--MediaBrowser.Controller/Net/IHttpResultFactory.cs2
5 files changed, 52 insertions, 16 deletions
diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs
index 4aa99ae87b..efc4502481 100644
--- a/MediaBrowser.Controller/Entities/AggregateFolder.cs
+++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs
@@ -5,6 +5,8 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Providers;
@@ -84,7 +86,7 @@ namespace MediaBrowser.Controller.Entities
}
}
- private void ResetCachedChildren()
+ private void ClearCache()
{
lock (_childIdsLock)
{
@@ -114,7 +116,7 @@ namespace MediaBrowser.Controller.Entities
public override bool BeforeMetadataRefresh()
{
- ResetCachedChildren();
+ ClearCache();
var changed = base.BeforeMetadataRefresh() || _requiresRefresh;
_requiresRefresh = false;
@@ -123,7 +125,7 @@ namespace MediaBrowser.Controller.Entities
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
{
- ResetCachedChildren();
+ ClearCache();
var path = ContainingFolderPath;
@@ -165,6 +167,21 @@ namespace MediaBrowser.Controller.Entities
return args;
}
+ protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
+ {
+ return base.GetNonCachedChildren(directoryService).Concat(_virtualChildren);
+ }
+
+ 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>
/// Adds the virtual child.
/// </summary>
@@ -181,15 +198,6 @@ namespace MediaBrowser.Controller.Entities
}
/// <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>
/// Finds the virtual child.
/// </summary>
/// <param name="id">The id.</param>
diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs
index d043cba47f..bd25d3a6ae 100644
--- a/MediaBrowser.Controller/Entities/UserRootFolder.cs
+++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs
@@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Entities
}
}
- private void ResetCachedChildren()
+ private void ClearCache()
{
lock (_childIdsLock)
{
@@ -94,7 +94,7 @@ namespace MediaBrowser.Controller.Entities
public override bool BeforeMetadataRefresh()
{
- ResetCachedChildren();
+ ClearCache();
var hasChanges = base.BeforeMetadataRefresh();
@@ -107,13 +107,22 @@ namespace MediaBrowser.Controller.Entities
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)
{
- ResetCachedChildren();
+ ClearCache();
await base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService)
.ConfigureAwait(false);
+ ClearCache();
+
// Not the best way to handle this, but it solves an issue
// CollectionFolders aren't always getting saved after changes
// This means that grabbing the item by Id may end up returning the old one
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 0462117cb5..e7eaa1dc0b 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -236,6 +236,7 @@
<Compile Include="Net\IAuthorizationContext.cs" />
<Compile Include="Net\IAuthService.cs" />
<Compile Include="Net\IHasAuthorization.cs" />
+ <Compile Include="Net\IAsyncStreamSource.cs" />
<Compile Include="Net\IHasResultFactory.cs" />
<Compile Include="Net\IHasSession.cs" />
<Compile Include="Net\IHttpResultFactory.cs" />
diff --git a/MediaBrowser.Controller/Net/IAsyncStreamSource.cs b/MediaBrowser.Controller/Net/IAsyncStreamSource.cs
new file mode 100644
index 0000000000..0f41f60a55
--- /dev/null
+++ b/MediaBrowser.Controller/Net/IAsyncStreamSource.cs
@@ -0,0 +1,18 @@
+using ServiceStack.Web;
+using System.IO;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.Net
+{
+ /// <summary>
+ /// Interface IAsyncStreamSource
+ /// Enables asynchronous writing to http resonse streams
+ /// </summary>
+ public interface IAsyncStreamSource
+ {
+ /// <summary>
+ /// Asynchronously write to the response stream.
+ /// </summary>
+ Task WriteToAsync(Stream responseStream);
+ }
+}
diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs
index 49d4614d81..8fdb1ce37e 100644
--- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs
+++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs
@@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.Net
/// <returns>System.Object.</returns>
object GetResult(object content, string contentType, IDictionary<string,string> responseHeaders = null);
- object GetAsyncStreamWriter(Func<Stream,Task> streamWriter, IDictionary<string, string> responseHeaders = null);
+ object GetAsyncStreamWriter(IAsyncStreamSource streamSource);
/// <summary>
/// Gets the optimized result.