mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Fix:Clear library filter data cache when library item is updated #2597
This commit is contained in:
		
							parent
							
								
									acf75abdf1
								
							
						
					
					
						commit
						a43b93d796
					
				@ -419,10 +419,21 @@ class Database {
 | 
				
			|||||||
    await this.models.libraryItem.fullCreateFromOld(oldLibraryItem)
 | 
					    await this.models.libraryItem.fullCreateFromOld(oldLibraryItem)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Save metadata file and update library item
 | 
				
			||||||
 | 
					   * 
 | 
				
			||||||
 | 
					   * @param {import('./objects/LibraryItem')} oldLibraryItem 
 | 
				
			||||||
 | 
					   * @returns {Promise<boolean>}
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
  async updateLibraryItem(oldLibraryItem) {
 | 
					  async updateLibraryItem(oldLibraryItem) {
 | 
				
			||||||
    if (!this.sequelize) return false
 | 
					    if (!this.sequelize) return false
 | 
				
			||||||
    await oldLibraryItem.saveMetadata()
 | 
					    await oldLibraryItem.saveMetadata()
 | 
				
			||||||
    return this.models.libraryItem.fullUpdateFromOld(oldLibraryItem)
 | 
					    const updated = await this.models.libraryItem.fullUpdateFromOld(oldLibraryItem)
 | 
				
			||||||
 | 
					    // Clear library filter data cache
 | 
				
			||||||
 | 
					    if (updated) {
 | 
				
			||||||
 | 
					      delete this.libraryFilterData[oldLibraryItem.libraryId]
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return updated
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  async removeLibraryItem(libraryItemId) {
 | 
					  async removeLibraryItem(libraryItemId) {
 | 
				
			||||||
 | 
				
			|||||||
@ -225,6 +225,12 @@ class LibraryItem extends Model {
 | 
				
			|||||||
    return newLibraryItem
 | 
					    return newLibraryItem
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Updates libraryItem, book, authors and series from old library item
 | 
				
			||||||
 | 
					   * 
 | 
				
			||||||
 | 
					   * @param {oldLibraryItem} oldLibraryItem 
 | 
				
			||||||
 | 
					   * @returns {Promise<boolean>} true if updates were made
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
  static async fullUpdateFromOld(oldLibraryItem) {
 | 
					  static async fullUpdateFromOld(oldLibraryItem) {
 | 
				
			||||||
    const libraryItemExpanded = await this.findByPk(oldLibraryItem.id, {
 | 
					    const libraryItemExpanded = await this.findByPk(oldLibraryItem.id, {
 | 
				
			||||||
      include: [
 | 
					      include: [
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user