mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-11-24 08:42:19 +02:00
Fixed: A potential issue when extra files for multiple series have the same relative path
This commit is contained in:
parent
9183c6b846
commit
a6a68b4cae
@ -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 @@ public List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public interface IExtraFileService<TExtraFile>
|
||||
{
|
||||
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 @@ public List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId)
|
||||
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)
|
||||
|
@ -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 @@ public void RenameOtherExtraFile(Series series, string path)
|
||||
}
|
||||
|
||||
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 @@ private void RemoveOtherExtraFile(Series series, string path)
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user