mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-11-04 03:17:00 -05:00 
			
		
		
		
	when checking if series/author is alread in DB, use case insensitive match only for ASCII names
This commit is contained in:
		
							parent
							
								
									01fbea02f1
								
							
						
					
					
						commit
						def34a860b
					
				@ -53,6 +53,17 @@ class Author extends Model {
 | 
				
			|||||||
   * @returns {Promise<Author>}
 | 
					   * @returns {Promise<Author>}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  static async getByNameAndLibrary(authorName, libraryId) {
 | 
					  static async getByNameAndLibrary(authorName, libraryId) {
 | 
				
			||||||
 | 
					    const containsOnlyASCII = /^[\u0000-\u007f]*$/.test(authorName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // SQLite does not support lower with non-Unicode chars
 | 
				
			||||||
 | 
					    if (!containsOnlyASCII) {
 | 
				
			||||||
 | 
					      return this.findOne({
 | 
				
			||||||
 | 
					        where: {
 | 
				
			||||||
 | 
					          name: authorName,
 | 
				
			||||||
 | 
					          libraryId: libraryId
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
      return this.findOne({
 | 
					      return this.findOne({
 | 
				
			||||||
        where: [
 | 
					        where: [
 | 
				
			||||||
          where(fn('lower', col('name')), authorName.toLowerCase()),
 | 
					          where(fn('lower', col('name')), authorName.toLowerCase()),
 | 
				
			||||||
@ -62,6 +73,7 @@ class Author extends Model {
 | 
				
			|||||||
        ]
 | 
					        ]
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
 | 
				
			|||||||
@ -39,6 +39,17 @@ class Series extends Model {
 | 
				
			|||||||
   * @returns {Promise<Series>}
 | 
					   * @returns {Promise<Series>}
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  static async getByNameAndLibrary(seriesName, libraryId) {
 | 
					  static async getByNameAndLibrary(seriesName, libraryId) {
 | 
				
			||||||
 | 
					    const containsOnlyASCII = /^[\u0000-\u007f]*$/.test(authorName)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // SQLite does not support lower with non-Unicode chars
 | 
				
			||||||
 | 
					    if (!containsOnlyASCII) {
 | 
				
			||||||
 | 
					      return this.findOne({
 | 
				
			||||||
 | 
					        where: {
 | 
				
			||||||
 | 
					          name: seriesName,
 | 
				
			||||||
 | 
					          libraryId: libraryId
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
      return this.findOne({
 | 
					      return this.findOne({
 | 
				
			||||||
        where: [
 | 
					        where: [
 | 
				
			||||||
          where(fn('lower', col('name')), seriesName.toLowerCase()),
 | 
					          where(fn('lower', col('name')), seriesName.toLowerCase()),
 | 
				
			||||||
@ -48,6 +59,7 @@ class Series extends Model {
 | 
				
			|||||||
        ]
 | 
					        ]
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Initialize model
 | 
					   * Initialize model
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user