mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 05:25:10 +00:00
Fixed: A potential issue when extra files for multiple artists have the same relative path
(cherry picked from commit a6a68b4cae7688506c45ff6cf10989fe6596c274) Closes #2760
This commit is contained in:
parent
2f0d02b3bc
commit
0bdd5f3278
3 changed files with 8 additions and 8 deletions
|
@ -14,7 +14,7 @@ public interface IExtraFileRepository<TExtraFile> : IBasicRepository<TExtraFile>
|
|||
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 @@ public List<TExtraFile> GetFilesByTrackFile(int trackFileId)
|
|||
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 @@ public interface IExtraFileService<TExtraFile>
|
|||
{
|
||||
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 @@ public List<TExtraFile> GetFilesByTrackFile(int trackFileId)
|
|||
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 @@ public void RenameOtherExtraFile(Artist artist, string path)
|
|||
}
|
||||
|
||||
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 @@ private void RemoveOtherExtraFile(Artist artist, string path)
|
|||
}
|
||||
|
||||
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…
Reference in a new issue