New: Bulk Delete for Unmapped Files

(cherry picked from commit 71c1edd47c5377bcdeeb68e9cededf122a6ce6b4)
This commit is contained in:
Qstick
2023-01-14 23:31:01 -06:00
committed by Bogdan
parent 9865e92cea
commit cf415e61de
9 changed files with 204 additions and 12 deletions

View File

@@ -242,6 +242,7 @@
"DeleteRemotePathMappingMessageText": "Are you sure you want to delete this remote path mapping?",
"DeleteRootFolder": "Delete Root Folder",
"DeleteRootFolderMessageText": "Are you sure you want to delete the root folder '{name}'?",
"DeleteSelected": "Delete Selected",
"DeleteSelectedBookFiles": "Delete Selected Book Files",
"DeleteSelectedBookFilesMessageText": "Are you sure you want to delete the selected book files?",
"DeleteSelectedDownloadClients": "Delete Download Client(s)",

View File

@@ -156,17 +156,23 @@ namespace Readarr.Api.V1.BookFiles
}
[HttpDelete("bulk")]
public IActionResult DeleteBookFiles([FromBody] BookFileListResource resource)
public object DeleteTrackFiles([FromBody] BookFileListResource resource)
{
var bookFiles = _mediaFileService.Get(resource.BookFileIds);
var author = bookFiles.First().Author.Value;
foreach (var bookFile in bookFiles)
{
_mediaFileDeletionService.DeleteTrackFile(author, bookFile);
if (bookFile.EditionId > 0 && bookFile.Author != null && bookFile.Author.Value != null)
{
_mediaFileDeletionService.DeleteTrackFile(bookFile.Author.Value, bookFile);
}
else
{
_mediaFileDeletionService.DeleteTrackFile(bookFile, "Unmapped_Files");
}
}
return Ok();
return new { };
}
[NonAction]