mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-26 00:14:49 +01:00
Fix updating cover from match requests #3807
This commit is contained in:
parent
ed5960825b
commit
8286aad7a4
@ -266,7 +266,7 @@ class LibraryItemController {
|
|||||||
*
|
*
|
||||||
* @param {LibraryItemControllerRequest} req
|
* @param {LibraryItemControllerRequest} req
|
||||||
* @param {Response} res
|
* @param {Response} res
|
||||||
* @param {boolean} [updateAndReturnJson=true]
|
* @param {boolean} [updateAndReturnJson=true] - Allows the function to be used for both direct API calls and internally
|
||||||
*/
|
*/
|
||||||
async uploadCover(req, res, updateAndReturnJson = true) {
|
async uploadCover(req, res, updateAndReturnJson = true) {
|
||||||
if (!req.user.canUpload) {
|
if (!req.user.canUpload) {
|
||||||
@ -291,11 +291,11 @@ class LibraryItemController {
|
|||||||
return res.status(500).send('Unknown error occurred')
|
return res.status(500).send('Unknown error occurred')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updateAndReturnJson) {
|
req.libraryItem.media.coverPath = result.cover
|
||||||
req.libraryItem.media.coverPath = result.cover
|
req.libraryItem.media.changed('coverPath', true)
|
||||||
req.libraryItem.media.changed('coverPath', true)
|
await req.libraryItem.media.save()
|
||||||
await req.libraryItem.media.save()
|
|
||||||
|
|
||||||
|
if (updateAndReturnJson) {
|
||||||
// client uses updatedAt timestamp in URL to force refresh cover
|
// client uses updatedAt timestamp in URL to force refresh cover
|
||||||
req.libraryItem.changed('updatedAt', true)
|
req.libraryItem.changed('updatedAt', true)
|
||||||
await req.libraryItem.save()
|
await req.libraryItem.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user