Fixed: IOE when multiple movies have same ExtraFile relative paths

Fixes RADARR-15
pull/4810/head
Qstick 4 years ago
parent 94ec28ac1e
commit 1a9d7c3c28

@ -12,7 +12,6 @@ namespace NzbDrone.Core.Extras.Files
void DeleteForMovieFile(int movieFileId); void DeleteForMovieFile(int movieFileId);
List<TExtraFile> GetFilesByMovie(int movieId); List<TExtraFile> GetFilesByMovie(int movieId);
List<TExtraFile> GetFilesByMovieFile(int movieFileId); List<TExtraFile> GetFilesByMovieFile(int movieFileId);
TExtraFile FindByPath(string path);
} }
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile> public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
@ -42,10 +41,5 @@ namespace NzbDrone.Core.Extras.Files
{ {
return Query(x => x.MovieFileId == movieFileId); return Query(x => x.MovieFileId == movieFileId);
} }
public TExtraFile FindByPath(string path)
{
return Query(x => x.RelativePath == path).SingleOrDefault();
}
} }
} }

@ -17,7 +17,6 @@ namespace NzbDrone.Core.Extras.Files
{ {
List<TExtraFile> GetFilesByMovie(int movieId); List<TExtraFile> GetFilesByMovie(int movieId);
List<TExtraFile> GetFilesByMovieFile(int movieFileId); List<TExtraFile> GetFilesByMovieFile(int movieFileId);
TExtraFile FindByPath(string path);
void Upsert(TExtraFile extraFile); void Upsert(TExtraFile extraFile);
void Upsert(List<TExtraFile> extraFiles); void Upsert(List<TExtraFile> extraFiles);
void Delete(int id); void Delete(int id);
@ -58,11 +57,6 @@ namespace NzbDrone.Core.Extras.Files
return _repository.GetFilesByMovieFile(movieFileId); return _repository.GetFilesByMovieFile(movieFileId);
} }
public TExtraFile FindByPath(string path)
{
return _repository.FindByPath(path);
}
public void Upsert(TExtraFile extraFile) public void Upsert(TExtraFile extraFile)
{ {
Upsert(new List<TExtraFile> { extraFile }); Upsert(new List<TExtraFile> { extraFile });

@ -1,3 +1,4 @@
using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
@ -16,11 +17,9 @@ namespace NzbDrone.Core.Extras.Others
private readonly Logger _logger; private readonly Logger _logger;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IRecycleBinProvider _recycleBinProvider; private readonly IRecycleBinProvider _recycleBinProvider;
private readonly IMovieService _movieService;
private readonly IOtherExtraFileService _otherExtraFileService; private readonly IOtherExtraFileService _otherExtraFileService;
public OtherExtraFileRenamer(IOtherExtraFileService otherExtraFileService, public OtherExtraFileRenamer(IOtherExtraFileService otherExtraFileService,
IMovieService movieService,
IRecycleBinProvider recycleBinProvider, IRecycleBinProvider recycleBinProvider,
IDiskProvider diskProvider, IDiskProvider diskProvider,
Logger logger) Logger logger)
@ -28,7 +27,6 @@ namespace NzbDrone.Core.Extras.Others
_logger = logger; _logger = logger;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_recycleBinProvider = recycleBinProvider; _recycleBinProvider = recycleBinProvider;
_movieService = movieService;
_otherExtraFileService = otherExtraFileService; _otherExtraFileService = otherExtraFileService;
} }
@ -41,7 +39,7 @@ namespace NzbDrone.Core.Extras.Others
var relativePath = movie.Path.GetRelativePath(path); var relativePath = movie.Path.GetRelativePath(path);
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath); var otherExtraFile = _otherExtraFileService.GetFilesByMovie(movie.Id).Where(e => e.RelativePath == relativePath).SingleOrDefault();
if (otherExtraFile != null) if (otherExtraFile != null)
{ {
var newPath = path + "-orig"; var newPath = path + "-orig";
@ -66,7 +64,7 @@ namespace NzbDrone.Core.Extras.Others
var relativePath = movie.Path.GetRelativePath(path); var relativePath = movie.Path.GetRelativePath(path);
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath); var otherExtraFile = _otherExtraFileService.GetFilesByMovie(movie.Id).Where(e => e.RelativePath == relativePath).SingleOrDefault();
if (otherExtraFile != null) if (otherExtraFile != null)
{ {
_recycleBinProvider.DeleteFile(path); _recycleBinProvider.DeleteFile(path);

Loading…
Cancel
Save