mirror of
https://github.com/Readarr/Readarr
synced 2025-12-29 03:34:35 +01:00
Fixed: A potential issue when extra files for multiple authors have the same relative path
(cherry picked from commit a6a68b4cae7688506c45ff6cf10989fe6596c274) Closes #1650
This commit is contained in:
parent
02fd733223
commit
44009e980b
3 changed files with 8 additions and 8 deletions
|
|
@ -14,7 +14,7 @@ public interface IExtraFileRepository<TExtraFile> : IBasicRepository<TExtraFile>
|
|||
List<TExtraFile> GetFilesByAuthor(int authorId);
|
||||
List<TExtraFile> GetFilesByBook(int authorId, int bookId);
|
||||
List<TExtraFile> GetFilesByBookFile(int bookFileId);
|
||||
TExtraFile FindByPath(string path);
|
||||
TExtraFile FindByPath(int authorId, string path);
|
||||
}
|
||||
|
||||
public class ExtraFileRepository<TExtraFile> : BasicRepository<TExtraFile>, IExtraFileRepository<TExtraFile>
|
||||
|
|
@ -55,9 +55,9 @@ public List<TExtraFile> GetFilesByBookFile(int bookFileId)
|
|||
return Query(c => c.BookFileId == bookFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(string path)
|
||||
public TExtraFile FindByPath(int authorId, string path)
|
||||
{
|
||||
return Query(c => c.RelativePath == path).SingleOrDefault();
|
||||
return Query(c => c.AuthorId == authorId && c.RelativePath == path).SingleOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public interface IExtraFileService<TExtraFile>
|
|||
{
|
||||
List<TExtraFile> GetFilesByAuthor(int authorId);
|
||||
List<TExtraFile> GetFilesByBookFile(int bookFileId);
|
||||
TExtraFile FindByPath(string path);
|
||||
TExtraFile FindByPath(int authorId, string path);
|
||||
void Upsert(TExtraFile extraFile);
|
||||
void Upsert(List<TExtraFile> extraFiles);
|
||||
void Delete(int id);
|
||||
|
|
@ -59,9 +59,9 @@ public List<TExtraFile> GetFilesByBookFile(int bookFileId)
|
|||
return _repository.GetFilesByBookFile(bookFileId);
|
||||
}
|
||||
|
||||
public TExtraFile FindByPath(string path)
|
||||
public TExtraFile FindByPath(int authorId, string path)
|
||||
{
|
||||
return _repository.FindByPath(path);
|
||||
return _repository.FindByPath(authorId, path);
|
||||
}
|
||||
|
||||
public void Upsert(TExtraFile extraFile)
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public void RenameOtherExtraFile(Author author, string path)
|
|||
}
|
||||
|
||||
var relativePath = author.Path.GetRelativePath(path);
|
||||
var otherExtraFile = _otherExtraFileService.FindByPath(author.Id, relativePath);
|
||||
|
||||
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
|
||||
if (otherExtraFile != null)
|
||||
{
|
||||
var newPath = path + "-orig";
|
||||
|
|
@ -66,8 +66,8 @@ private void RemoveOtherExtraFile(Author author, string path)
|
|||
}
|
||||
|
||||
var relativePath = author.Path.GetRelativePath(path);
|
||||
var otherExtraFile = _otherExtraFileService.FindByPath(author.Id, relativePath);
|
||||
|
||||
var otherExtraFile = _otherExtraFileService.FindByPath(relativePath);
|
||||
if (otherExtraFile != null)
|
||||
{
|
||||
var subfolder = Path.GetDirectoryName(relativePath);
|
||||
|
|
|
|||
Loading…
Reference in a new issue