mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Fixed: IOE when multiple movies have same ExtraFile relative paths
Fixes RADARR-15
This commit is contained in:
parent
94ec28ac1e
commit
1a9d7c3c28
@ -12,7 +12,6 @@ public interface IExtraFileRepository<TExtraFile> : IBasicRepository<TExtraFile>
|
|||||||
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 @@ public List<TExtraFile> GetFilesByMovieFile(int movieFileId)
|
|||||||
{
|
{
|
||||||
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 @@ public interface IExtraFileService<TExtraFile>
|
|||||||
{
|
{
|
||||||
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 @@ public List<TExtraFile> GetFilesByMovieFile(int movieFileId)
|
|||||||
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 @@ public class OtherExtraFileRenamer : IOtherExtraFileRenamer
|
|||||||
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 @@ public OtherExtraFileRenamer(IOtherExtraFileService otherExtraFileService,
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_diskProvider = diskProvider;
|
_diskProvider = diskProvider;
|
||||||
_recycleBinProvider = recycleBinProvider;
|
_recycleBinProvider = recycleBinProvider;
|
||||||
_movieService = movieService;
|
|
||||||
_otherExtraFileService = otherExtraFileService;
|
_otherExtraFileService = otherExtraFileService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +39,7 @@ public void RenameOtherExtraFile(Movie movie, string path)
|
|||||||
|
|
||||||
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 @@ private void RemoveOtherExtraFile(Movie movie, string path)
|
|||||||
|
|
||||||
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…
Reference in New Issue
Block a user