BaseXmlProvider.cs 886 B

12345678910111213141516171819202122232425262728293031323334
  1. using MediaBrowser.Common.IO;
  2. using MediaBrowser.Controller.Providers;
  3. using System;
  4. using System.IO;
  5. using System.Threading;
  6. namespace MediaBrowser.Providers
  7. {
  8. public abstract class BaseXmlProvider: IHasChangeMonitor
  9. {
  10. protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(4, 4);
  11. protected IFileSystem FileSystem;
  12. protected BaseXmlProvider(IFileSystem fileSystem)
  13. {
  14. FileSystem = fileSystem;
  15. }
  16. protected abstract string GetXmlPath(string path);
  17. public bool HasChanged(IHasMetadata item, DateTime date)
  18. {
  19. var path = GetXmlPath(item.Path);
  20. return FileSystem.GetLastWriteTimeUtc(path) > date;
  21. }
  22. public bool HasLocalMetadata(IHasMetadata item)
  23. {
  24. return File.Exists(GetXmlPath(item.Path));
  25. }
  26. }
  27. }