aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library/LibraryStructureService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/Library/LibraryStructureService.cs')
-rw-r--r--MediaBrowser.Api/Library/LibraryStructureService.cs63
1 files changed, 39 insertions, 24 deletions
diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs
index 775907379..8ea472da3 100644
--- a/MediaBrowser.Api/Library/LibraryStructureService.cs
+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs
@@ -167,6 +167,17 @@ 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>
+ [ApiMember(Name = "Path", Description = "The path that was changed.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string Path { get; set; }
+ }
+
/// <summary>
/// Class LibraryStructureService
/// </summary>
@@ -187,7 +198,7 @@ namespace MediaBrowser.Api.Library
/// </summary>
private readonly ILibraryManager _libraryManager;
- private readonly IDirectoryWatchers _directoryWatchers;
+ private readonly ILibraryMonitor _libraryMonitor;
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
@@ -199,7 +210,7 @@ namespace MediaBrowser.Api.Library
/// <param name="userManager">The user manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <exception cref="System.ArgumentNullException">appPaths</exception>
- public LibraryStructureService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IDirectoryWatchers directoryWatchers, IFileSystem fileSystem, ILogger logger)
+ public LibraryStructureService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem, ILogger logger)
{
if (appPaths == null)
{
@@ -209,12 +220,27 @@ namespace MediaBrowser.Api.Library
_userManager = userManager;
_appPaths = appPaths;
_libraryManager = libraryManager;
- _directoryWatchers = directoryWatchers;
+ _libraryMonitor = libraryMonitor;
_fileSystem = fileSystem;
_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>
/// <param name="request">The request.</param>
@@ -270,8 +296,7 @@ namespace MediaBrowser.Api.Library
throw new ArgumentException("There is already a media collection with the name " + name + ".");
}
- _directoryWatchers.Stop();
- _directoryWatchers.TemporarilyIgnore(virtualFolderPath);
+ _libraryMonitor.Stop();
try
{
@@ -294,10 +319,8 @@ namespace MediaBrowser.Api.Library
// No need to start if scanning the library because it will handle it
if (!request.RefreshLibrary)
{
- _directoryWatchers.Start();
+ _libraryMonitor.Start();
}
-
- _directoryWatchers.RemoveTempIgnore(virtualFolderPath);
}
if (request.RefreshLibrary)
@@ -348,9 +371,7 @@ namespace MediaBrowser.Api.Library
throw new ArgumentException("There is already a media collection with the name " + newPath + ".");
}
- _directoryWatchers.Stop();
- _directoryWatchers.TemporarilyIgnore(currentPath);
- _directoryWatchers.TemporarilyIgnore(newPath);
+ _libraryMonitor.Stop();
try
{
@@ -376,11 +397,8 @@ namespace MediaBrowser.Api.Library
// No need to start if scanning the library because it will handle it
if (!request.RefreshLibrary)
{
- _directoryWatchers.Start();
+ _libraryMonitor.Start();
}
-
- _directoryWatchers.RemoveTempIgnore(currentPath);
- _directoryWatchers.RemoveTempIgnore(newPath);
}
if (request.RefreshLibrary)
@@ -420,8 +438,7 @@ namespace MediaBrowser.Api.Library
throw new DirectoryNotFoundException("The media folder does not exist");
}
- _directoryWatchers.Stop();
- _directoryWatchers.TemporarilyIgnore(path);
+ _libraryMonitor.Stop();
try
{
@@ -437,10 +454,8 @@ namespace MediaBrowser.Api.Library
// No need to start if scanning the library because it will handle it
if (!request.RefreshLibrary)
{
- _directoryWatchers.Start();
+ _libraryMonitor.Start();
}
-
- _directoryWatchers.RemoveTempIgnore(path);
}
if (request.RefreshLibrary)
@@ -460,7 +475,7 @@ namespace MediaBrowser.Api.Library
throw new ArgumentNullException("request");
}
- _directoryWatchers.Stop();
+ _libraryMonitor.Stop();
try
{
@@ -485,7 +500,7 @@ namespace MediaBrowser.Api.Library
// No need to start if scanning the library because it will handle it
if (!request.RefreshLibrary)
{
- _directoryWatchers.Start();
+ _libraryMonitor.Start();
}
}
@@ -506,7 +521,7 @@ namespace MediaBrowser.Api.Library
throw new ArgumentNullException("request");
}
- _directoryWatchers.Stop();
+ _libraryMonitor.Stop();
try
{
@@ -531,7 +546,7 @@ namespace MediaBrowser.Api.Library
// No need to start if scanning the library because it will handle it
if (!request.RefreshLibrary)
{
- _directoryWatchers.Start();
+ _libraryMonitor.Start();
}
}