|
|
|
@ -23,6 +23,7 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MediaFileDeletionService : IDeleteMediaFiles,
|
|
|
|
|
IHandle<AuthorDeletedEvent>,
|
|
|
|
|
IHandleAsync<AuthorDeletedEvent>,
|
|
|
|
|
IHandleAsync<BookDeletedEvent>,
|
|
|
|
|
IHandle<BookFileDeletedEvent>
|
|
|
|
@ -121,11 +122,36 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[EventHandleOrder(EventHandleOrder.First)]
|
|
|
|
|
public void Handle(AuthorDeletedEvent message)
|
|
|
|
|
{
|
|
|
|
|
if (message.DeleteFiles)
|
|
|
|
|
{
|
|
|
|
|
var author = message.Author;
|
|
|
|
|
|
|
|
|
|
var rootFolder = _rootFolderService.GetBestRootFolder(message.Author.Path);
|
|
|
|
|
var isCalibre = rootFolder.IsCalibreLibrary && rootFolder.CalibreSettings != null;
|
|
|
|
|
|
|
|
|
|
if (isCalibre)
|
|
|
|
|
{
|
|
|
|
|
// use metadataId instead of authorId so that query works even after author deleted
|
|
|
|
|
var books = _mediaFileService.GetFilesByAuthorMetadataId(author.AuthorMetadataId);
|
|
|
|
|
_calibre.DeleteBooks(books, rootFolder.CalibreSettings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HandleAsync(AuthorDeletedEvent message)
|
|
|
|
|
{
|
|
|
|
|
if (message.DeleteFiles)
|
|
|
|
|
{
|
|
|
|
|
var author = message.Author;
|
|
|
|
|
|
|
|
|
|
var rootFolder = _rootFolderService.GetBestRootFolder(message.Author.Path);
|
|
|
|
|
var isCalibre = rootFolder.IsCalibreLibrary && rootFolder.CalibreSettings != null;
|
|
|
|
|
|
|
|
|
|
if (!isCalibre)
|
|
|
|
|
{
|
|
|
|
|
var allAuthors = _authorService.AllAuthorPaths();
|
|
|
|
|
|
|
|
|
|
foreach (var s in allAuthors)
|
|
|
|
@ -154,6 +180,7 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HandleAsync(BookDeletedEvent message)
|
|
|
|
|
{
|
|
|
|
|