aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-01-28 16:51:47 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-01-28 16:51:47 -0500
commit40b8300e8e72245c802938cd335a7ee962f8193f (patch)
tree53406e2b73976bfc7aed48e7b260a4a6d92349dc /MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
parent7c5b22246357ef6bcd6d74e61a8fe6a8a9d4df3e (diff)
added api for external apps to report file system changes
Diffstat (limited to 'MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs')
-rw-r--r--MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs41
1 files changed, 29 insertions, 12 deletions
diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
index e09e66765..bf90dc40e 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;
+
/// <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,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;