@ -12,7 +12,6 @@ using System.Collections.Generic;
using System.Threading ;
using System.Threading ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using CommonIO ;
using CommonIO ;
using MediaBrowser.Controller.Channels ;
using MediaBrowser.Controller.Entities.Audio ;
using MediaBrowser.Controller.Entities.Audio ;
namespace MediaBrowser.Server.Implementations.Persistence
namespace MediaBrowser.Server.Implementations.Persistence
@ -25,8 +24,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
private readonly IServerConfigurationManager _config ;
private readonly IServerConfigurationManager _config ;
private readonly IFileSystem _fileSystem ;
private readonly IFileSystem _fileSystem ;
public const int MigrationVersion = 4 ;
public CleanDatabaseScheduledTask ( ILibraryManager libraryManager , IItemRepository itemRepo , ILogger logger , IServerConfigurationManager config , IFileSystem fileSystem )
public CleanDatabaseScheduledTask ( ILibraryManager libraryManager , IItemRepository itemRepo , ILogger logger , IServerConfigurationManager config , IFileSystem fileSystem )
{
{
_libraryManager = libraryManager ;
_libraryManager = libraryManager ;
@ -67,8 +64,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
innerProgress . RegisterAction ( p = > progress . Report ( 45 + ( . 55 * p ) ) ) ;
innerProgress . RegisterAction ( p = > progress . Report ( 45 + ( . 55 * p ) ) ) ;
await CleanDeletedItems ( cancellationToken , innerProgress ) . ConfigureAwait ( false ) ;
await CleanDeletedItems ( cancellationToken , innerProgress ) . ConfigureAwait ( false ) ;
progress . Report ( 100 ) ;
progress . Report ( 100 ) ;
await _itemRepo . UpdateInheritedValues ( cancellationToken ) . ConfigureAwait ( false ) ;
}
}
private async Task UpdateToLatestSchema ( CancellationToken cancellationToken , IProgress < double > progress )
private async Task UpdateToLatestSchema ( CancellationToken cancellationToken , IProgress < double > progress )
@ -120,9 +115,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
progress . Report ( percent * 100 ) ;
progress . Report ( percent * 100 ) ;
}
}
if ( _config . Configuration . MigrationVersion < MigrationVersio n)
if ( ! _config . Configuration . DisableStartupSca n)
{
{
_config . Configuration . MigrationVersion = MigrationVersion ;
_config . Configuration . DisableStartupScan = true ;
_config . SaveConfiguration ( ) ;
_config . SaveConfiguration ( ) ;
}
}
@ -149,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
if ( item ! = null )
if ( item ! = null )
{
{
_logger . Debug ( "Cleaning item {0} type: {1} path: {2}" , item . Name , item . GetType ( ) . Name , item . Path ? ? string . Empty ) ;
_logger . Info ( "Cleaning item {0} type: {1} path: {2}" , item . Name , item . GetType ( ) . Name , item . Path ? ? string . Empty ) ;
await _libraryManager . DeleteItem ( item , new DeleteOptions
await _libraryManager . DeleteItem ( item , new DeleteOptions
{
{
@ -175,18 +170,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
//Limit = limit,
//Limit = limit,
// These have their own cleanup routines
// These have their own cleanup routines
ExcludeItemTypes = new [ ]
ExcludeItemTypes = new [ ] { typeof ( Person ) . Name , typeof ( Genre ) . Name , typeof ( MusicGenre ) . Name , typeof ( GameGenre ) . Name , typeof ( Studio ) . Name , typeof ( Year ) . Name }
{
typeof ( Person ) . Name ,
typeof ( Genre ) . Name ,
typeof ( MusicGenre ) . Name ,
typeof ( GameGenre ) . Name ,
typeof ( Studio ) . Name ,
typeof ( Year ) . Name ,
typeof ( Channel ) . Name ,
typeof ( AggregateFolder ) . Name ,
typeof ( CollectionFolder ) . Name
}
} ) ;
} ) ;
var numComplete = 0 ;
var numComplete = 0 ;
@ -214,6 +198,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
continue ;
continue ;
}
}
_logger . Info ( "Deleting item from database {0} because path no longer exists. type: {1} path: {2}" , libraryItem . Name , libraryItem . GetType ( ) . Name , libraryItem . Path ? ? string . Empty ) ;
await _libraryManager . DeleteItem ( libraryItem , new DeleteOptions
await _libraryManager . DeleteItem ( libraryItem , new DeleteOptions
{
{
DeleteFileLocation = false
DeleteFileLocation = false