added api for external apps to report file system changes
This commit is contained in:
parent
7c5b222463
commit
40b8300e8e
|
@ -167,6 +167,16 @@ namespace MediaBrowser.Api.Library
|
|||
public bool RefreshLibrary { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Library/Changes/Path", "POST")]
|
||||
public class ReportChangedPath : IReturnVoid
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Path { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class LibraryStructureService
|
||||
/// </summary>
|
||||
|
@ -214,6 +224,21 @@ namespace MediaBrowser.Api.Library
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <exception cref="System.ArgumentException">Please supply a Path</exception>
|
||||
public void Post(ReportChangedPath request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Path))
|
||||
{
|
||||
throw new ArgumentException("Please supply a Path");
|
||||
}
|
||||
|
||||
_libraryMonitor.ReportFileSystemChanged(request.Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
|
@ -72,11 +73,21 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
|
||||
public void ReportFileSystemChangeBeginning(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
TemporarilyIgnore(path);
|
||||
}
|
||||
|
||||
public void ReportFileSystemChangeComplete(string path, bool refreshPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
RemoveTempIgnore(path);
|
||||
|
||||
if (refreshPath)
|
||||
|
@ -100,6 +111,8 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
private ILibraryManager LibraryManager { get; set; }
|
||||
private IServerConfigurationManager ConfigurationManager { get; set; }
|
||||
|
||||
private IFileSystem _fileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibraryMonitor" /> class.
|
||||
/// </summary>
|
||||
|
@ -350,6 +363,11 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
|
||||
public void ReportFileSystemChanged(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
var filename = Path.GetFileName(path);
|
||||
|
||||
// Ignore certain files
|
||||
|
@ -369,8 +387,16 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
return true;
|
||||
}
|
||||
|
||||
if (_fileSystem.ContainsSubPath(i, path))
|
||||
{
|
||||
Logger.Debug("Ignoring change to {0}", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Go up a level
|
||||
var parent = Path.GetDirectoryName(i);
|
||||
if (!string.IsNullOrEmpty(parent))
|
||||
{
|
||||
if (string.Equals(parent, path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Logger.Debug("Ignoring change to {0}", path);
|
||||
|
@ -378,8 +404,6 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
}
|
||||
|
||||
// Go up another level
|
||||
if (!string.IsNullOrEmpty(parent))
|
||||
{
|
||||
parent = Path.GetDirectoryName(i);
|
||||
if (string.Equals(parent, path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
|
@ -388,13 +412,6 @@ namespace MediaBrowser.Server.Implementations.IO
|
|||
}
|
||||
}
|
||||
|
||||
if (i.StartsWith(path, StringComparison.OrdinalIgnoreCase) ||
|
||||
path.StartsWith(i, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Logger.Debug("Ignoring change to {0}", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue
Block a user