mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 17:44:43 +01:00
fix folder caching
This commit is contained in:
@@ -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,16 @@ namespace MediaBrowser.Controller.Entities
|
||||
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>
|
||||
/// Adds the virtual child.
|
||||
/// </summary>
|
||||
@@ -180,15 +192,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
_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>
|
||||
/// Finds the virtual child.
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user