diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-02-06 01:08:55 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-06 01:08:55 -0500 |
| commit | 2ceaa50ea737e88aca74c4af16a5c969e07d5f5a (patch) | |
| tree | f74ffd55b84f50b36f7f99b75dc10c5c27bc5b91 /Emby.Server.Core/IO/LibraryMonitor.cs | |
| parent | 84d2a5303b2eee311628876851335b7b926aa2ea (diff) | |
| parent | 6f1a300bdef907415160728670726735067efc7a (diff) | |
Merge pull request #2445 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Core/IO/LibraryMonitor.cs')
| -rw-r--r-- | Emby.Server.Core/IO/LibraryMonitor.cs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Emby.Server.Core/IO/LibraryMonitor.cs b/Emby.Server.Core/IO/LibraryMonitor.cs index f0ecb9d89..baa705111 100644 --- a/Emby.Server.Core/IO/LibraryMonitor.cs +++ b/Emby.Server.Core/IO/LibraryMonitor.cs @@ -283,18 +283,24 @@ namespace Emby.Server.Core.IO /// <param name="path">The path.</param> private void StartWatchingPath(string path) { + if (!_fileSystem.DirectoryExists(path)) + { + // Seeing a crash in the mono runtime due to an exception being thrown on a different thread + Logger.Info("Skipping realtime monitor for {0} because the path does not exist", path); + return; + } + + // Already being watched + if (_fileSystemWatchers.ContainsKey(path)) + { + return; + } + // Creating a FileSystemWatcher over the LAN can take hundreds of milliseconds, so wrap it in a Task to do them all in parallel Task.Run(() => { try { - if (!_fileSystem.DirectoryExists(path)) - { - // Seeing a crash in the mono runtime due to an exception being thrown on a different thread - Logger.Info("Skipping realtime monitor for {0} because the path does not exist", path); - return; - } - var newWatcher = new FileSystemWatcher(path, "*") { IncludeSubdirectories = true @@ -326,7 +332,6 @@ namespace Emby.Server.Core.IO } else { - Logger.Info("Unable to add directory watcher for {0}. It already exists in the dictionary.", path); newWatcher.Dispose(); } |
