mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
Pull ProviderData out of memory
This commit is contained in:
@@ -201,29 +201,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _provider data
|
||||
/// </summary>
|
||||
private Dictionary<Guid, BaseProviderInfo> _providerData;
|
||||
/// <summary>
|
||||
/// Holds persistent data for providers like last refresh date.
|
||||
/// Providers can use this to determine if they need to refresh.
|
||||
/// The BaseProviderInfo class can be extended to hold anything a provider may need.
|
||||
/// Keyed by a unique provider ID.
|
||||
/// </summary>
|
||||
/// <value>The provider data.</value>
|
||||
public Dictionary<Guid, BaseProviderInfo> ProviderData
|
||||
{
|
||||
get
|
||||
{
|
||||
return _providerData ?? (_providerData = new Dictionary<Guid, BaseProviderInfo>());
|
||||
}
|
||||
set
|
||||
{
|
||||
_providerData = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the media.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -111,6 +112,22 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveMediaStreams(Guid id, IEnumerable<MediaStream> streams, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the provider history.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <returns>IEnumerable{BaseProviderInfo}.</returns>
|
||||
IEnumerable<BaseProviderInfo> GetProviderHistory(Guid itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the provider history.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="history">The history.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveProviderHistory(Guid id, IEnumerable<BaseProviderInfo> history, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <summary>
|
||||
/// The _id
|
||||
/// </summary>
|
||||
protected readonly Guid Id;
|
||||
public readonly Guid Id;
|
||||
|
||||
/// <summary>
|
||||
/// The true task result
|
||||
@@ -132,41 +132,33 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="providerVersion">The provider version.</param>
|
||||
/// <param name="providerInfo">The provider information.</param>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <exception cref="System.ArgumentNullException">item</exception>
|
||||
public virtual void SetLastRefreshed(BaseItem item, DateTime value, string providerVersion,
|
||||
ProviderRefreshStatus status = ProviderRefreshStatus.Success)
|
||||
BaseProviderInfo providerInfo, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
|
||||
BaseProviderInfo data;
|
||||
|
||||
if (!item.ProviderData.TryGetValue(Id, out data))
|
||||
{
|
||||
data = new BaseProviderInfo();
|
||||
}
|
||||
|
||||
data.LastRefreshed = value;
|
||||
data.LastRefreshStatus = status;
|
||||
data.ProviderVersion = providerVersion;
|
||||
providerInfo.LastRefreshed = value;
|
||||
providerInfo.LastRefreshStatus = status;
|
||||
providerInfo.ProviderVersion = providerVersion;
|
||||
|
||||
// Save the file system stamp for future comparisons
|
||||
if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem)
|
||||
{
|
||||
try
|
||||
{
|
||||
data.FileStamp = GetCurrentFileSystemStamp(item);
|
||||
providerInfo.FileStamp = GetCurrentFileSystemStamp(item);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.ErrorException("Error getting file stamp for {0}", ex, item.Path);
|
||||
}
|
||||
}
|
||||
|
||||
item.ProviderData[Id] = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,11 +166,12 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="providerInfo">The provider information.</param>
|
||||
/// <param name="status">The status.</param>
|
||||
public void SetLastRefreshed(BaseItem item, DateTime value,
|
||||
ProviderRefreshStatus status = ProviderRefreshStatus.Success)
|
||||
BaseProviderInfo providerInfo, ProviderRefreshStatus status = ProviderRefreshStatus.Success)
|
||||
{
|
||||
SetLastRefreshed(item, value, ProviderVersion, status);
|
||||
SetLastRefreshed(item, value, ProviderVersion, providerInfo, status);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,20 +182,13 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
public bool NeedsRefresh(BaseItem item)
|
||||
public bool NeedsRefresh(BaseItem item, BaseProviderInfo data)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
BaseProviderInfo data;
|
||||
|
||||
if (!item.ProviderData.TryGetValue(Id, out data))
|
||||
{
|
||||
data = new BaseProviderInfo();
|
||||
}
|
||||
|
||||
return NeedsRefreshInternal(item, data);
|
||||
}
|
||||
|
||||
@@ -299,10 +285,11 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||
/// <param name="providerInfo">The provider information.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{System.Boolean}.</returns>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
public abstract Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken);
|
||||
public abstract Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public class BaseProviderInfo
|
||||
{
|
||||
public Guid ProviderId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the last refreshed.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user