Skip to content

Commit 0bdd5f3

Browse files
markus101mynameisbogdan
authored andcommittedFeb 5, 2024
Fixed: A potential issue when extra files for multiple artists have the same relative path
(cherry picked from commit a6a68b4cae7688506c45ff6cf10989fe6596c274) Closes #2760
1 parent 2f0d02b commit 0bdd5f3

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed
 

‎src/NzbDrone.Core/Extras/Files/ExtraFileRepository.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IExtraFileRepository<TExtraFile> : IBasicRepository<TExtraFile>
1414
List<TExtraFile> GetFilesByArtist(int artistId);
1515
List<TExtraFile> GetFilesByAlbum(int artistId, int albumId);
1616
List<TExtraFile> GetFilesByTrackFile(int trackFileId);
17-
TExtraFile FindByPath(string path);
17+
TExtraFile FindByPath(int artistId, string path);
1818
}
1919

2020
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
@@ -55,9 +55,9 @@ public List<TExtraFile> GetFilesByTrackFile(int trackFileId)
5555
return Query(c => c.TrackFileId == trackFileId);
5656
}
5757

58-
public TExtraFile FindByPath(string path)
58+
public TExtraFile FindByPath(int artistId, string path)
5959
{
60-
return Query(c => c.RelativePath == path).SingleOrDefault();
60+
return Query(c => c.ArtistId == artistId && c.RelativePath == path).SingleOrDefault();
6161
}
6262
}
6363
}

‎src/NzbDrone.Core/Extras/Files/ExtraFileService.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IExtraFileService<TExtraFile>
1818
{
1919
List<TExtraFile> GetFilesByArtist(int artistId);
2020
List<TExtraFile> GetFilesByTrackFile(int trackFileId);
21-
TExtraFile FindByPath(string path);
21+
TExtraFile FindByPath(int artistId, string path);
2222
void Upsert(TExtraFile extraFile);
2323
void Upsert(List<TExtraFile> extraFiles);
2424
void Delete(int id);
@@ -59,9 +59,9 @@ public List<TExtraFile> GetFilesByTrackFile(int trackFileId)
5959
return _repository.GetFilesByTrackFile(trackFileId);
6060
}
6161

62-
public TExtraFile FindByPath(string path)
62+
public TExtraFile FindByPath(int artistId, string path)
6363
{
64-
return _repository.FindByPath(path);
64+
return _repository.FindByPath(artistId, path);
6565
}
6666

6767
public void Upsert(TExtraFile extraFile)

‎src/NzbDrone.Core/Extras/Others/OtherExtraFileRenamer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public void RenameOtherExtraFile(Artist artist, string path)
4141
}
4242

4343
var relativePath = artist.Path.GetRelativePath(path);
44+
var otherExtraFile = _otherExtraFileService.FindByPath(artist.Id, relativePath);
4445

45-
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
4646
if (otherExtraFile != null)
4747
{
4848
var newPath = path + "-orig";
@@ -66,8 +66,8 @@ private void RemoveOtherExtraFile(Artist artist, string path)
6666
}
6767

6868
var relativePath = artist.Path.GetRelativePath(path);
69+
var otherExtraFile = _otherExtraFileService.FindByPath(artist.Id, relativePath);
6970

70-
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
7171
if (otherExtraFile != null)
7272
{
7373
var subfolder = Path.GetDirectoryName(relativePath);

0 commit comments

Comments
 (0)
Please sign in to comment.