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> GetFilesBySeries(int seriesId);
|
||||||
List<TExtraFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
List<TExtraFile> GetFilesBySeason(int seriesId, int seasonNumber);
|
||||||
List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId);
|
List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId);
|
||||||
TExtraFile FindByPath(string path);
|
TExtraFile FindByPath(int seriesId, string path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
|
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
|
||||||
|
@ -54,9 +54,9 @@ namespace NzbDrone.Core.Extras.Files
|
||||||
return Query.Where(c => c.EpisodeFileId == 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 @@ namespace NzbDrone.Core.Extras.Files
|
||||||
{
|
{
|
||||||
List<TExtraFile> GetFilesBySeries(int seriesId);
|
List<TExtraFile> GetFilesBySeries(int seriesId);
|
||||||
List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId);
|
List<TExtraFile> GetFilesByEpisodeFile(int episodeFileId);
|
||||||
TExtraFile FindByPath(string path);
|
TExtraFile FindByPath(int seriesId, 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);
|
||||||
|
@ -59,9 +59,9 @@ namespace NzbDrone.Core.Extras.Files
|
||||||
return _repository.GetFilesByEpisodeFile(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)
|
public void Upsert(TExtraFile extraFile)
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
using System;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
@ -45,8 +41,8 @@ namespace NzbDrone.Core.Extras.Others
|
||||||
}
|
}
|
||||||
|
|
||||||
var relativePath = series.Path.GetRelativePath(path);
|
var relativePath = series.Path.GetRelativePath(path);
|
||||||
|
var otherExtraFile = _otherExtraFileService.FindByPath(series.Id, relativePath);
|
||||||
|
|
||||||
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
|
|
||||||
if (otherExtraFile != null)
|
if (otherExtraFile != null)
|
||||||
{
|
{
|
||||||
var newPath = path + "-orig";
|
var newPath = path + "-orig";
|
||||||
|
@ -70,8 +66,8 @@ namespace NzbDrone.Core.Extras.Others
|
||||||
}
|
}
|
||||||
|
|
||||||
var relativePath = series.Path.GetRelativePath(path);
|
var relativePath = series.Path.GetRelativePath(path);
|
||||||
|
var otherExtraFile = _otherExtraFileService.FindByPath(series.Id, relativePath);
|
||||||
|
|
||||||
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
|
|
||||||
if (otherExtraFile != null)
|
if (otherExtraFile != null)
|
||||||
{
|
{
|
||||||
var subfolder = Path.GetDirectoryName(relativePath);
|
var subfolder = Path.GetDirectoryName(relativePath);
|
||||||
|
|
Loading…
Reference in New Issue