aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library/LibraryStructureService.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-03-18 23:47:21 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-03-18 23:47:21 -0400
commitc87c516ea32b8c9bdd01f76c453b65bf24f9ce86 (patch)
tree5455f0bba7974fdc0f484d5de36a31a5b86e910c /MediaBrowser.Api/Library/LibraryStructureService.cs
parentaac044f18f11009fc4911b509f4d6dd4c0d56f56 (diff)
updated nuget
Diffstat (limited to 'MediaBrowser.Api/Library/LibraryStructureService.cs')
-rw-r--r--MediaBrowser.Api/Library/LibraryStructureService.cs150
1 files changed, 80 insertions, 70 deletions
diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs
index 27944a4ea..f5fe921ce 100644
--- a/MediaBrowser.Api/Library/LibraryStructureService.cs
+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs
@@ -212,24 +212,26 @@ namespace MediaBrowser.Api.Library
File.Create(path);
}
-
- // Need to add a delay here or directory watchers may still pick up the changes
- var task = Task.Delay(1000);
- // Have to block here to allow exceptions to bubble
- Task.WaitAll(task);
}
finally
{
- // No need to start if scanning the library because it will handle it
- if (!request.RefreshLibrary)
+ Task.Run(() =>
{
- _libraryMonitor.Start();
- }
- }
-
- if (request.RefreshLibrary)
- {
- _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ // No need to start if scanning the library because it will handle it
+ if (request.RefreshLibrary)
+ {
+ _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ }
+ else
+ {
+ // Need to add a delay here or directory watchers may still pick up the changes
+ var task = Task.Delay(1000);
+ // Have to block here to allow exceptions to bubble
+ Task.WaitAll(task);
+
+ _libraryMonitor.Start();
+ }
+ });
}
}
@@ -279,24 +281,26 @@ namespace MediaBrowser.Api.Library
}
Directory.Move(currentPath, newPath);
-
- // Need to add a delay here or directory watchers may still pick up the changes
- var task = Task.Delay(1000);
- // Have to block here to allow exceptions to bubble
- Task.WaitAll(task);
}
finally
{
- // No need to start if scanning the library because it will handle it
- if (!request.RefreshLibrary)
+ Task.Run(() =>
{
- _libraryMonitor.Start();
- }
- }
-
- if (request.RefreshLibrary)
- {
- _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ // No need to start if scanning the library because it will handle it
+ if (request.RefreshLibrary)
+ {
+ _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ }
+ else
+ {
+ // Need to add a delay here or directory watchers may still pick up the changes
+ var task = Task.Delay(1000);
+ // Have to block here to allow exceptions to bubble
+ Task.WaitAll(task);
+
+ _libraryMonitor.Start();
+ }
+ });
}
}
@@ -325,24 +329,26 @@ namespace MediaBrowser.Api.Library
try
{
_fileSystem.DeleteDirectory(path, true);
-
- // Need to add a delay here or directory watchers may still pick up the changes
- var delayTask = Task.Delay(1000);
- // Have to block here to allow exceptions to bubble
- Task.WaitAll(delayTask);
}
finally
{
- // No need to start if scanning the library because it will handle it
- if (!request.RefreshLibrary)
+ Task.Run(() =>
{
- _libraryMonitor.Start();
- }
- }
-
- if (request.RefreshLibrary)
- {
- _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ // No need to start if scanning the library because it will handle it
+ if (request.RefreshLibrary)
+ {
+ _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ }
+ else
+ {
+ // Need to add a delay here or directory watchers may still pick up the changes
+ var task = Task.Delay(1000);
+ // Have to block here to allow exceptions to bubble
+ Task.WaitAll(task);
+
+ _libraryMonitor.Start();
+ }
+ });
}
}
@@ -362,24 +368,26 @@ namespace MediaBrowser.Api.Library
try
{
LibraryHelpers.AddMediaPath(_fileSystem, request.Name, request.Path, _appPaths);
-
- // Need to add a delay here or directory watchers may still pick up the changes
- var task = Task.Delay(1000);
- // Have to block here to allow exceptions to bubble
- Task.WaitAll(task);
}
finally
{
- // No need to start if scanning the library because it will handle it
- if (!request.RefreshLibrary)
+ Task.Run(() =>
{
- _libraryMonitor.Start();
- }
- }
-
- if (request.RefreshLibrary)
- {
- _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ // No need to start if scanning the library because it will handle it
+ if (request.RefreshLibrary)
+ {
+ _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ }
+ else
+ {
+ // Need to add a delay here or directory watchers may still pick up the changes
+ var task = Task.Delay(1000);
+ // Have to block here to allow exceptions to bubble
+ Task.WaitAll(task);
+
+ _libraryMonitor.Start();
+ }
+ });
}
}
@@ -399,24 +407,26 @@ namespace MediaBrowser.Api.Library
try
{
LibraryHelpers.RemoveMediaPath(_fileSystem, request.Name, request.Path, _appPaths);
-
- // Need to add a delay here or directory watchers may still pick up the changes
- var task = Task.Delay(1000);
- // Have to block here to allow exceptions to bubble
- Task.WaitAll(task);
}
finally
{
- // No need to start if scanning the library because it will handle it
- if (!request.RefreshLibrary)
+ Task.Run(() =>
{
- _libraryMonitor.Start();
- }
- }
-
- if (request.RefreshLibrary)
- {
- _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ // No need to start if scanning the library because it will handle it
+ if (request.RefreshLibrary)
+ {
+ _libraryManager.ValidateMediaLibrary(new Progress<double>(), CancellationToken.None);
+ }
+ else
+ {
+ // Need to add a delay here or directory watchers may still pick up the changes
+ var task = Task.Delay(1000);
+ // Have to block here to allow exceptions to bubble
+ Task.WaitAll(task);
+
+ _libraryMonitor.Start();
+ }
+ });
}
}
}