diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupAdditionalUsers.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupAdditionalUsers.cs
index 62f58b962..c98d38793 100644
--- a/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupAdditionalUsers.cs
+++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/CleanupAdditionalUsers.cs
@@ -2,11 +2,11 @@
namespace NzbDrone.Core.Housekeeping.Housekeepers
{
- public class CleanupAdditionalUsers : IHousekeepingTask
+ public class FixWronglyMatchedMovieFiles : IHousekeepingTask
{
private readonly IMainDatabase _database;
- public CleanupAdditionalUsers(IMainDatabase database)
+ public FixWronglyMatchedMovieFiles(IMainDatabase database)
{
_database = database;
}
@@ -15,10 +15,11 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
{
var mapper = _database.GetDataMapper();
- mapper.ExecuteNonQuery(@"DELETE FROM Users
- WHERE ID NOT IN (
- SELECT ID FROM Users
- LIMIT 1)");
+ 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)");
}
}
}
diff --git a/src/NzbDrone.Core/Housekeeping/Housekeepers/FixWronglyMatchedMovieFiles.cs b/src/NzbDrone.Core/Housekeeping/Housekeepers/FixWronglyMatchedMovieFiles.cs
new file mode 100644
index 000000000..33070ce12
--- /dev/null
+++ b/src/NzbDrone.Core/Housekeeping/Housekeepers/FixWronglyMatchedMovieFiles.cs
@@ -0,0 +1,25 @@
+using NzbDrone.Core.Datastore;
+
+namespace NzbDrone.Core.Housekeeping.Housekeepers
+{
+ public class FixWronglyMatchedMovieFiles : IHousekeepingTask
+ {
+ private readonly IMainDatabase _database;
+
+ public FixWronglyMatchedMovieFiles(IMainDatabase database)
+ {
+ _database = database;
+ }
+
+ 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)");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index b60a75f43..a93d13303 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -1259,6 +1259,7 @@
+
diff --git a/src/NzbDrone.Core/Tv/MovieService.cs b/src/NzbDrone.Core/Tv/MovieService.cs
index e2585327e..fc3eb9fb2 100644
--- a/src/NzbDrone.Core/Tv/MovieService.cs
+++ b/src/NzbDrone.Core/Tv/MovieService.cs
@@ -331,13 +331,13 @@ namespace NzbDrone.Core.Tv
public void Handle(MovieFileAddedEvent message)
{
_movieRepository.SetFileId(message.MovieFile.Id, message.MovieFile.Movie.Value.Id);
- _logger.Debug("Linking [{0}] > [{1}]", message.MovieFile.RelativePath, message.MovieFile.Movie.Value);
+ _logger.Info("Linking [{0}] > [{1}]", message.MovieFile.RelativePath, message.MovieFile.Movie.Value);
}
public void SetFileId(Movie movie, MovieFile movieFile)
{
_movieRepository.SetFileId(movieFile.Id, movie.Id);
- _logger.Debug("Linking [{0}] > [{1}]", movieFile.RelativePath, movie);
+ _logger.Info("Linking [{0}] > [{1}]", movieFile.RelativePath, movie);
}
public void Handle(MovieFileDeletedEvent message)