diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs
index 56b0e01c3f..d0d56c07bf 100644
--- a/MediaBrowser.Api/Library/LibraryStructureService.cs
+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs
@@ -167,6 +167,16 @@ namespace MediaBrowser.Api.Library
public bool RefreshLibrary { get; set; }
}
+ [Route("/Library/Changes/Path", "POST")]
+ public class ReportChangedPath : IReturnVoid
+ {
+ ///
+ /// Gets or sets the name.
+ ///
+ /// The name.
+ public string Path { get; set; }
+ }
+
///
/// Class LibraryStructureService
///
@@ -214,6 +224,21 @@ namespace MediaBrowser.Api.Library
_logger = logger;
}
+ ///
+ /// Posts the specified request.
+ ///
+ /// The request.
+ /// Please supply a Path
+ public void Post(ReportChangedPath request)
+ {
+ if (string.IsNullOrEmpty(request.Path))
+ {
+ throw new ArgumentException("Please supply a Path");
+ }
+
+ _libraryMonitor.ReportFileSystemChanged(request.Path);
+ }
+
///
/// Gets the specified request.
///
diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
index e09e667651..bf90dc40ed 100644
--- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
+++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
@@ -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;
+
///
/// Initializes a new instance of the class.
///
@@ -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,30 +387,29 @@ namespace MediaBrowser.Server.Implementations.IO
return true;
}
- // Go up a level
- var parent = Path.GetDirectoryName(i);
- if (string.Equals(parent, path, StringComparison.OrdinalIgnoreCase))
+ if (_fileSystem.ContainsSubPath(i, path))
{
Logger.Debug("Ignoring change to {0}", path);
return true;
}
- // Go up another level
+ // Go up a level
+ var parent = Path.GetDirectoryName(i);
if (!string.IsNullOrEmpty(parent))
{
- parent = Path.GetDirectoryName(i);
if (string.Equals(parent, path, StringComparison.OrdinalIgnoreCase))
{
Logger.Debug("Ignoring change to {0}", path);
return true;
}
- }
- if (i.StartsWith(path, StringComparison.OrdinalIgnoreCase) ||
- path.StartsWith(i, StringComparison.OrdinalIgnoreCase))
- {
- Logger.Debug("Ignoring change to {0}", path);
- return true;
+ // Go up another level
+ parent = Path.GetDirectoryName(i);
+ if (string.Equals(parent, path, StringComparison.OrdinalIgnoreCase))
+ {
+ Logger.Debug("Ignoring change to {0}", path);
+ return true;
+ }
}
return false;