@ -44,6 +44,7 @@ namespace NzbDrone.Core.MediaFiles
private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService ;
private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService ;
private readonly IEventAggregator _eventAggregator ;
private readonly IEventAggregator _eventAggregator ;
private readonly IMovieService _movieService ;
private readonly IMovieService _movieService ;
private readonly IMovieFileRepository _movieFileRepository ;
private readonly Logger _logger ;
private readonly Logger _logger ;
public DiskScanService ( IDiskProvider diskProvider ,
public DiskScanService ( IDiskProvider diskProvider ,
@ -55,6 +56,7 @@ namespace NzbDrone.Core.MediaFiles
IMediaFileTableCleanupService mediaFileTableCleanupService ,
IMediaFileTableCleanupService mediaFileTableCleanupService ,
IEventAggregator eventAggregator ,
IEventAggregator eventAggregator ,
IMovieService movieService ,
IMovieService movieService ,
IMovieFileRepository movieFileRepository ,
Logger logger )
Logger logger )
{
{
_diskProvider = diskProvider ;
_diskProvider = diskProvider ;
@ -66,6 +68,7 @@ namespace NzbDrone.Core.MediaFiles
_mediaFileTableCleanupService = mediaFileTableCleanupService ;
_mediaFileTableCleanupService = mediaFileTableCleanupService ;
_eventAggregator = eventAggregator ;
_eventAggregator = eventAggregator ;
_movieService = movieService ;
_movieService = movieService ;
_movieFileRepository = movieFileRepository ;
_logger = logger ;
_logger = logger ;
}
}
@ -136,14 +139,14 @@ namespace NzbDrone.Core.MediaFiles
if ( ! _diskProvider . FolderExists ( rootFolder ) )
if ( ! _diskProvider . FolderExists ( rootFolder ) )
{
{
_logger . Warn ( " Ser ies' root folder ({0}) doesn't exist.", rootFolder ) ;
_logger . Warn ( " Mov ies' root folder ({0}) doesn't exist.", rootFolder ) ;
_eventAggregator . PublishEvent ( new MovieScanSkippedEvent ( movie , MovieScanSkippedReason . RootFolderDoesNotExist ) ) ;
_eventAggregator . PublishEvent ( new MovieScanSkippedEvent ( movie , MovieScanSkippedReason . RootFolderDoesNotExist ) ) ;
return ;
return ;
}
}
if ( _diskProvider . GetDirectories ( rootFolder ) . Empty ( ) )
if ( _diskProvider . GetDirectories ( rootFolder ) . Empty ( ) )
{
{
_logger . Warn ( " Ser ies' root folder ({0}) is empty.", rootFolder ) ;
_logger . Warn ( " Mov ies' root folder ({0}) is empty.", rootFolder ) ;
_eventAggregator . PublishEvent ( new MovieScanSkippedEvent ( movie , MovieScanSkippedReason . RootFolderIsEmpty ) ) ;
_eventAggregator . PublishEvent ( new MovieScanSkippedEvent ( movie , MovieScanSkippedReason . RootFolderIsEmpty ) ) ;
return ;
return ;
}
}
@ -155,13 +158,20 @@ namespace NzbDrone.Core.MediaFiles
if ( _configService . CreateEmptySeriesFolders & &
if ( _configService . CreateEmptySeriesFolders & &
_diskProvider . FolderExists ( rootFolder ) )
_diskProvider . FolderExists ( rootFolder ) )
{
{
_logger . Debug ( "Creating missing ser ies folder: {0}", movie . Path ) ;
_logger . Debug ( "Creating missing mov ies folder: {0}", movie . Path ) ;
_diskProvider . CreateFolder ( movie . Path ) ;
_diskProvider . CreateFolder ( movie . Path ) ;
SetPermissions ( movie . Path ) ;
SetPermissions ( movie . Path ) ;
}
}
else
else
{
{
_logger . Debug ( "Series folder doesn't exist: {0}" , movie . Path ) ;
// Delete Movie from MovieFiles
_movieFileRepository . Delete ( movie . MovieFileId ) ;
// Update Movie
movie . MovieFileId = 0 ;
_movieService . UpdateMovie ( movie ) ;
_logger . Debug ( "Movies folder doesn't exist: {0}" , movie . Path ) ;
}
}
_eventAggregator . PublishEvent ( new MovieScanSkippedEvent ( movie , MovieScanSkippedReason . MovieFolderDoesNotExist ) ) ;
_eventAggregator . PublishEvent ( new MovieScanSkippedEvent ( movie , MovieScanSkippedReason . MovieFolderDoesNotExist ) ) ;