mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix:Manually updating author image path & realtime update author image #1317
This commit is contained in:
		
							parent
							
								
									8acf962864
								
							
						
					
					
						commit
						45c9038954
					
				@ -109,7 +109,8 @@ export default {
 | 
			
		||||
      this.processing = true
 | 
			
		||||
      var result = await this.$axios.$patch(`/api/authors/${this.authorId}`, updatePayload).catch((error) => {
 | 
			
		||||
        console.error('Failed', error)
 | 
			
		||||
        this.$toast.error(this.$strings.ToastAuthorUpdateFailed)
 | 
			
		||||
        const errorMsg = error.response ? error.response.data : null
 | 
			
		||||
        this.$toast.error(errorMsg || this.$strings.ToastAuthorUpdateFailed)
 | 
			
		||||
        return null
 | 
			
		||||
      })
 | 
			
		||||
      if (result) {
 | 
			
		||||
 | 
			
		||||
@ -82,6 +82,15 @@ class AuthorController {
 | 
			
		||||
          payload.imagePath = imageData.path
 | 
			
		||||
          hasUpdated = true
 | 
			
		||||
        }
 | 
			
		||||
      } else if (payload.imagePath && payload.imagePath !== req.author.imagePath) { // Changing image path locally
 | 
			
		||||
        if (!await fs.pathExists(payload.imagePath)) { // Make sure image path exists
 | 
			
		||||
          Logger.error(`[AuthorController] Image path does not exist: "${payload.imagePath}"`)
 | 
			
		||||
          return res.status(400).send('Author image path does not exist')
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (req.author.imagePath) {
 | 
			
		||||
          await this.cacheManager.purgeImageCache(req.author.id) // Purge cache
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -119,6 +128,8 @@ class AuthorController {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (hasUpdated) {
 | 
			
		||||
        req.author.updatedAt = Date.now()
 | 
			
		||||
 | 
			
		||||
        if (authorNameUpdate) { // Update author name on all books
 | 
			
		||||
          const itemsWithAuthor = this.db.libraryItems.filter(li => li.mediaType === 'book' && li.media.metadata.hasAuthor(req.author.id))
 | 
			
		||||
          itemsWithAuthor.forEach(libraryItem => {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user