mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-22 08:53:41 +02:00
Update:Matching authors uses the ASIN if set #572, Fix:Purge author image cache when updating author
This commit is contained in:
parent
eaa383b6d8
commit
f78d287b59
7 changed files with 43 additions and 79 deletions
|
@ -107,11 +107,16 @@ class AuthorController {
|
|||
}
|
||||
|
||||
async match(req, res) {
|
||||
var authorData = await this.authorFinder.findAuthorByName(req.body.q)
|
||||
var authorData = null
|
||||
if (req.body.asin) {
|
||||
authorData = await this.authorFinder.findAuthorByASIN(req.body.asin)
|
||||
} else {
|
||||
authorData = await this.authorFinder.findAuthorByName(req.body.q)
|
||||
}
|
||||
if (!authorData) {
|
||||
return res.status(404).send('Author not found')
|
||||
}
|
||||
Logger.debug(`[AuthorController] match author with "${req.body.q}"`, authorData)
|
||||
Logger.debug(`[AuthorController] match author with "${req.body.q || req.body.asin}"`, authorData)
|
||||
|
||||
var hasUpdates = false
|
||||
if (authorData.asin && req.author.asin !== authorData.asin) {
|
||||
|
@ -121,6 +126,8 @@ class AuthorController {
|
|||
|
||||
// Only updates image if there was no image before or the author ASIN was updated
|
||||
if (authorData.image && (!req.author.imagePath || hasUpdates)) {
|
||||
this.cacheManager.purgeImageCache(req.author.id)
|
||||
|
||||
var imageData = await this.authorFinder.saveAuthorImage(req.author.id, authorData.image)
|
||||
if (imageData) {
|
||||
req.author.imagePath = imageData.path
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue