mirror of
https://github.com/Radarr/Radarr.git
synced 2026-03-05 13:21:25 -05:00
Fixed a potential issue when extra files for multiple movies have the same relative path
(cherry picked from commit a6a68b4cae7688506c45ff6cf10989fe6596c274) Closes #7222
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
|
||||
@@ -11,6 +12,7 @@ namespace NzbDrone.Core.Extras.Files
|
||||
void DeleteForMovieFile(int movieFileId);
|
||||
List<TExtraFile> GetFilesByMovie(int movieId);
|
||||
List<TExtraFile> GetFilesByMovieFile(int movieFileId);
|
||||
TExtraFile FindByPath(int movieId, string path);
|
||||
}
|
||||
|
||||
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
|
||||
@@ -40,5 +42,10 @@ namespace NzbDrone.Core.Extras.Files
|
||||
{
|
||||
return Query(x => x.MovieFileId == movieFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(int movieId, string path)
|
||||
{
|
||||
return Query(c => c.MovieId == movieId && c.RelativePath == path).SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace NzbDrone.Core.Extras.Files
|
||||
{
|
||||
List<TExtraFile> GetFilesByMovie(int movieId);
|
||||
List<TExtraFile> GetFilesByMovieFile(int movieFileId);
|
||||
TExtraFile FindByPath(int movieId, string path);
|
||||
void Upsert(TExtraFile extraFile);
|
||||
void Upsert(List<TExtraFile> extraFiles);
|
||||
void Delete(int id);
|
||||
@@ -58,6 +59,11 @@ namespace NzbDrone.Core.Extras.Files
|
||||
return _repository.GetFilesByMovieFile(movieFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(int movieId, string path)
|
||||
{
|
||||
return _repository.FindByPath(movieId, path);
|
||||
}
|
||||
|
||||
public void Upsert(TExtraFile extraFile)
|
||||
{
|
||||
Upsert(new List<TExtraFile> { extraFile });
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
@@ -38,8 +37,8 @@ namespace NzbDrone.Core.Extras.Others
|
||||
}
|
||||
|
||||
var relativePath = movie.Path.GetRelativePath(path);
|
||||
var otherExtraFile = _otherExtraFileService.FindByPath(movie.Id, relativePath);
|
||||
|
||||
var otherExtraFile = _otherExtraFileService.GetFilesByMovie(movie.Id).Where(e => e.RelativePath == relativePath).SingleOrDefault();
|
||||
if (otherExtraFile != null)
|
||||
{
|
||||
var newPath = path + "-orig";
|
||||
@@ -63,8 +62,8 @@ namespace NzbDrone.Core.Extras.Others
|
||||
}
|
||||
|
||||
var relativePath = movie.Path.GetRelativePath(path);
|
||||
var otherExtraFile = _otherExtraFileService.FindByPath(movie.Id, relativePath);
|
||||
|
||||
var otherExtraFile = _otherExtraFileService.GetFilesByMovie(movie.Id).Where(e => e.RelativePath == relativePath).SingleOrDefault();
|
||||
if (otherExtraFile != null)
|
||||
{
|
||||
_recycleBinProvider.DeleteFile(path);
|
||||
|
||||
Reference in New Issue
Block a user