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

(cherry picked from commit a6a68b4cae7688506c45ff6cf10989fe6596c274)

Closes #2760
pull/4546/head
Mark McDowall 2 years ago committed by Bogdan
parent 2f0d02b3bc
commit 0bdd5f3278

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Extras.Files
List<TExtraFile> GetFilesByArtist(int artistId);
List<TExtraFile> GetFilesByAlbum(int artistId, int albumId);
List<TExtraFile> GetFilesByTrackFile(int trackFileId);
TExtraFile FindByPath(string path);
TExtraFile FindByPath(int artistId, string path);
}
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
@ -55,9 +55,9 @@ namespace NzbDrone.Core.Extras.Files
return Query(c => c.TrackFileId == trackFileId);
}
public TExtraFile FindByPath(string path)
public TExtraFile FindByPath(int artistId, string path)
{
return Query(c => c.RelativePath == path).SingleOrDefault();
return Query(c => c.ArtistId == artistId && c.RelativePath == path).SingleOrDefault();
}
}
}

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Extras.Files
{
List<TExtraFile> GetFilesByArtist(int artistId);
List<TExtraFile> GetFilesByTrackFile(int trackFileId);
TExtraFile FindByPath(string path);
TExtraFile FindByPath(int artistId, 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.GetFilesByTrackFile(trackFileId);
}
public TExtraFile FindByPath(string path)
public TExtraFile FindByPath(int artistId, string path)
{
return _repository.FindByPath(path);
return _repository.FindByPath(artistId, path);
}
public void Upsert(TExtraFile extraFile)

@ -41,8 +41,8 @@ namespace NzbDrone.Core.Extras.Others
}
var relativePath = artist.Path.GetRelativePath(path);
var otherExtraFile = _otherExtraFileService.FindByPath(artist.Id, relativePath);
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
if (otherExtraFile != null)
{
var newPath = path + "-orig";
@ -66,8 +66,8 @@ namespace NzbDrone.Core.Extras.Others
}
var relativePath = artist.Path.GetRelativePath(path);
var otherExtraFile = _otherExtraFileService.FindByPath(artist.Id, relativePath);
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
if (otherExtraFile != null)
{
var subfolder = Path.GetDirectoryName(relativePath);

Loading…
Cancel
Save