@ -212,25 +212,27 @@ namespace MediaBrowser.Api.Library
File . Create ( path ) ;
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
finally
{
{
// No need to start if scanning the library because it will handle it
Task . Run ( ( ) = >
if ( ! request . RefreshLibrary )
{
{
_libraryMonitor . Start ( ) ;
// No need to start if scanning the library because it will handle it
}
}
if ( request . RefreshLibrary )
if ( request . RefreshLibrary )
{
{
_libraryManager . ValidateMediaLibrary ( new Progress < double > ( ) , CancellationToken . None ) ;
_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 ( ) ;
}
} ) ;
}
}
}
/// <summary>
/// <summary>
@ -279,25 +281,27 @@ namespace MediaBrowser.Api.Library
}
}
Directory . Move ( currentPath , newPath ) ;
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
finally
{
{
// No need to start if scanning the library because it will handle it
Task . Run ( ( ) = >
if ( ! request . RefreshLibrary )
{
{
_libraryMonitor . Start ( ) ;
// No need to start if scanning the library because it will handle it
}
}
if ( request . RefreshLibrary )
if ( request . RefreshLibrary )
{
{
_libraryManager . ValidateMediaLibrary ( new Progress < double > ( ) , CancellationToken . None ) ;
_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 ( ) ;
}
} ) ;
}
}
}
/// <summary>
/// <summary>
@ -325,25 +329,27 @@ namespace MediaBrowser.Api.Library
try
try
{
{
_fileSystem . DeleteDirectory ( path , true ) ;
_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
finally
{
{
// No need to start if scanning the library because it will handle it
Task . Run ( ( ) = >
if ( ! request . RefreshLibrary )
{
{
_libraryMonitor . Start ( ) ;
// No need to start if scanning the library because it will handle it
}
}
if ( request . RefreshLibrary )
if ( request . RefreshLibrary )
{
{
_libraryManager . ValidateMediaLibrary ( new Progress < double > ( ) , CancellationToken . None ) ;
_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 ( ) ;
}
} ) ;
}
}
}
/// <summary>
/// <summary>
@ -362,25 +368,27 @@ namespace MediaBrowser.Api.Library
try
try
{
{
LibraryHelpers . AddMediaPath ( _fileSystem , request . Name , request . Path , _appPaths ) ;
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
finally
{
{
// No need to start if scanning the library because it will handle it
Task . Run ( ( ) = >
if ( ! request . RefreshLibrary )
{
{
_libraryMonitor . Start ( ) ;
// No need to start if scanning the library because it will handle it
}
}
if ( request . RefreshLibrary )
if ( request . RefreshLibrary )
{
{
_libraryManager . ValidateMediaLibrary ( new Progress < double > ( ) , CancellationToken . None ) ;
_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 ( ) ;
}
} ) ;
}
}
}
/// <summary>
/// <summary>
@ -399,25 +407,27 @@ namespace MediaBrowser.Api.Library
try
try
{
{
LibraryHelpers . RemoveMediaPath ( _fileSystem , request . Name , request . Path , _appPaths ) ;
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
finally
{
{
// No need to start if scanning the library because it will handle it
Task . Run ( ( ) = >
if ( ! request . RefreshLibrary )
{
{
_libraryMonitor . Start ( ) ;
// No need to start if scanning the library because it will handle it
}
}
if ( request . RefreshLibrary )
if ( request . RefreshLibrary )
{
{
_libraryManager . ValidateMediaLibrary ( new Progress < double > ( ) , CancellationToken . None ) ;
_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 ( ) ;
}
} ) ;
}
}
}
}
}
}
}