mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 10:32:35 +01:00
Ammend to previous commit.
This commit is contained in:
parent
0db27d9029
commit
a25c056def
@ -2,24 +2,24 @@
|
||||
|
||||
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
||||
{
|
||||
public class FixWronglyMatchedMovieFiles : IHousekeepingTask
|
||||
{
|
||||
private readonly IMainDatabase _database;
|
||||
public class CleanupAdditionalUsers : IHousekeepingTask
|
||||
{
|
||||
private readonly IMainDatabase _database;
|
||||
|
||||
public FixWronglyMatchedMovieFiles(IMainDatabase database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
public CleanupAdditionalUsers(IMainDatabase database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
{
|
||||
var mapper = _database.GetDataMapper();
|
||||
public void Clean()
|
||||
{
|
||||
var mapper = _database.GetDataMapper();
|
||||
|
||||
mapper.ExecuteNonQuery(@"UPDATE Movies
|
||||
SET MovieFileId =
|
||||
(Select Id FROM MovieFiles WHERE Movies.Id == MovieFiles.MovieId)
|
||||
WHERE MovieFileId !=
|
||||
(SELECT Id FROM MovieFiles WHERE Movies.Id == MovieFiles.MovieId)");
|
||||
}
|
||||
}
|
||||
mapper.ExecuteNonQuery(@"DELETE FROM Users
|
||||
WHERE ID NOT IN (
|
||||
SELECT ID FROM Users
|
||||
LIMIT 1)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,12 @@ public void HandleAsync(SeriesDeletedEvent message)
|
||||
public MovieFile Add(MovieFile episodeFile)
|
||||
{
|
||||
var addedFile = _movieFileRepository.Insert(episodeFile);
|
||||
episodeFile.Movie.LazyLoad();
|
||||
_movieService.SetFileId(episodeFile.Movie.Value, episodeFile); //Should not be necessary, but sometimes below fails?
|
||||
addedFile.Movie.LazyLoad();
|
||||
if (addedFile.Movie == null || addedFile.Movie.Value == null)
|
||||
{
|
||||
_logger.Error("Movie is null for the file {0}. Please run the houskeeping command to ensure movies and files are linked correctly.");
|
||||
}
|
||||
_movieService.SetFileId(addedFile.Movie.Value, addedFile); //Should not be necessary, but sometimes below fails?
|
||||
_eventAggregator.PublishEvent(new MovieFileAddedEvent(addedFile));
|
||||
|
||||
return addedFile;
|
||||
|
Loading…
Reference in New Issue
Block a user