You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Providers/BaseXmlProvider.cs

35 lines
886 B

using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Providers;
using System;
using System.IO;
using System.Threading;
namespace MediaBrowser.Providers
{
public abstract class BaseXmlProvider: IHasChangeMonitor
{
protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(4, 4);
protected IFileSystem FileSystem;
protected BaseXmlProvider(IFileSystem fileSystem)
{
FileSystem = fileSystem;
}
protected abstract string GetXmlPath(string path);
public bool HasChanged(IHasMetadata item, DateTime date)
{
var path = GetXmlPath(item.Path);
return FileSystem.GetLastWriteTimeUtc(path) > date;
}
public bool HasLocalMetadata(IHasMetadata item)
{
return File.Exists(GetXmlPath(item.Path));
}
}
}