mirror of
https://github.com/Radarr/Radarr
synced 2025-02-25 07:32:56 +00:00
Fixed: IOE when multiple movies have same ExtraFile relative paths
Fixes RADARR-15
This commit is contained in:
parent
94ec28ac1e
commit
1a9d7c3c28
3 changed files with 3 additions and 17 deletions
|
@ -12,7 +12,6 @@ public interface IExtraFileRepository<TExtraFile> : IBasicRepository<TExtraFile>
|
|||
void DeleteForMovieFile(int movieFileId);
|
||||
List<TExtraFile> GetFilesByMovie(int movieId);
|
||||
List<TExtraFile> GetFilesByMovieFile(int movieFileId);
|
||||
TExtraFile FindByPath(string path);
|
||||
}
|
||||
|
||||
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
|
||||
|
@ -42,10 +41,5 @@ public List<TExtraFile> GetFilesByMovieFile(int movieFileId)
|
|||
{
|
||||
return Query(x => x.MovieFileId == movieFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(string path)
|
||||
{
|
||||
return Query(x => x.RelativePath == path).SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ public interface IExtraFileService<TExtraFile>
|
|||
{
|
||||
List<TExtraFile> GetFilesByMovie(int movieId);
|
||||
List<TExtraFile> GetFilesByMovieFile(int movieFileId);
|
||||
TExtraFile FindByPath(string path);
|
||||
void Upsert(TExtraFile extraFile);
|
||||
void Upsert(List<TExtraFile> extraFiles);
|
||||
void Delete(int id);
|
||||
|
@ -58,11 +57,6 @@ public List<TExtraFile> GetFilesByMovieFile(int movieFileId)
|
|||
return _repository.GetFilesByMovieFile(movieFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(string path)
|
||||
{
|
||||
return _repository.FindByPath(path);
|
||||
}
|
||||
|
||||
public void Upsert(TExtraFile extraFile)
|
||||
{
|
||||
Upsert(new List<TExtraFile> { extraFile });
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
@ -16,11 +17,9 @@ public class OtherExtraFileRenamer : IOtherExtraFileRenamer
|
|||
private readonly Logger _logger;
|
||||
private readonly IDiskProvider _diskProvider;
|
||||
private readonly IRecycleBinProvider _recycleBinProvider;
|
||||
private readonly IMovieService _movieService;
|
||||
private readonly IOtherExtraFileService _otherExtraFileService;
|
||||
|
||||
public OtherExtraFileRenamer(IOtherExtraFileService otherExtraFileService,
|
||||
IMovieService movieService,
|
||||
IRecycleBinProvider recycleBinProvider,
|
||||
IDiskProvider diskProvider,
|
||||
Logger logger)
|
||||
|
@ -28,7 +27,6 @@ public OtherExtraFileRenamer(IOtherExtraFileService otherExtraFileService,
|
|||
_logger = logger;
|
||||
_diskProvider = diskProvider;
|
||||
_recycleBinProvider = recycleBinProvider;
|
||||
_movieService = movieService;
|
||||
_otherExtraFileService = otherExtraFileService;
|
||||
}
|
||||
|
||||
|
@ -41,7 +39,7 @@ public void RenameOtherExtraFile(Movie movie, string 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)
|
||||
{
|
||||
var newPath = path + "-orig";
|
||||
|
@ -66,7 +64,7 @@ private void RemoveOtherExtraFile(Movie movie, string 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)
|
||||
{
|
||||
_recycleBinProvider.DeleteFile(path);
|
||||
|
|
Loading…
Reference in a new issue