Fixed: A potential issue when extra files for multiple series have the same relative path

This commit is contained in:
Mark McDowall 2022-04-12 17:46:10 -07:00
parent 9183c6b846
commit a6a68b4cae
3 changed files with 9 additions and 13 deletions

View File

@ -13,7 +13,7 @@ namespace NzbDrone.Core.Extras.Files
List<TExtraFile> GetFilesBySeries(int seriesId);
List<TExtraFile> GetFilesBySeason(int seriesId, int seasonNumber);
List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId);
TExtraFile FindByPath(string path);
TExtraFile FindByPath(int seriesId, string path);
}
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
@ -54,9 +54,9 @@ namespace NzbDrone.Core.Extras.Files
return Query.Where(c => c.EpisodeFileId == episodeFileId);
}
public TExtraFile FindByPath(string path)
public TExtraFile FindByPath(int seriesId, string path)
{
return Query.Where(c => c.RelativePath == path).SingleOrDefault();
return Query.Where(c => c.SeriesId == seriesId && c.RelativePath == path).SingleOrDefault();
}
}
}

View File

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Extras.Files
{
List<TExtraFile> GetFilesBySeries(int seriesId);
List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId);
TExtraFile FindByPath(string path);
TExtraFile FindByPath(int seriesId, string path);
void Upsert(TExtraFile extraFile);
void Upsert(List<TExtraFile> extraFiles);
void Delete(int id);
@ -59,9 +59,9 @@ namespace NzbDrone.Core.Extras.Files
return _repository.GetFilesByEpisodeFile(episodeFileId);
}
public TExtraFile FindByPath(string path)
public TExtraFile FindByPath(int seriesId, string path)
{
return _repository.FindByPath(path);
return _repository.FindByPath(seriesId, path);
}
public void Upsert(TExtraFile extraFile)

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.IO;
using NLog;
using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions;
@ -45,8 +41,8 @@ namespace NzbDrone.Core.Extras.Others
}
var relativePath = series.Path.GetRelativePath(path);
var otherExtraFile = _otherExtraFileService.FindByPath(series.Id, relativePath);
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
if (otherExtraFile != null)
{
var newPath = path + "-orig";
@ -70,8 +66,8 @@ namespace NzbDrone.Core.Extras.Others
}
var relativePath = series.Path.GetRelativePath(path);
var otherExtraFile = _otherExtraFileService.FindByPath(series.Id, relativePath);
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
if (otherExtraFile != null)
{
var subfolder = Path.GetDirectoryName(relativePath);