2014-01-28 18:37:01 +00:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using System;
|
2014-01-29 16:16:24 +00:00
|
|
|
|
using System.IO;
|
2014-01-28 18:37:01 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 13:36:31 +00:00
|
|
|
|
protected abstract FileInfo GetXmlFile(string path);
|
2014-01-28 18:37:01 +00:00
|
|
|
|
|
|
|
|
|
public bool HasChanged(IHasMetadata item, DateTime date)
|
|
|
|
|
{
|
2014-02-02 13:36:31 +00:00
|
|
|
|
var file = GetXmlFile(item.Path);
|
2014-01-28 18:37:01 +00:00
|
|
|
|
|
2014-02-02 13:36:31 +00:00
|
|
|
|
return FileSystem.GetLastWriteTimeUtc(file) > date;
|
2014-01-28 18:37:01 +00:00
|
|
|
|
}
|
2014-01-29 16:16:24 +00:00
|
|
|
|
|
|
|
|
|
public bool HasLocalMetadata(IHasMetadata item)
|
|
|
|
|
{
|
2014-02-02 13:36:31 +00:00
|
|
|
|
return GetXmlFile(item.Path).Exists;
|
2014-01-29 16:16:24 +00:00
|
|
|
|
}
|
2014-01-28 18:37:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|