mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Cleanup and remove more vars
This commit is contained in:
		
							parent
							
								
									45c9038954
								
							
						
					
					
						commit
						775dedc338
					
				| @ -198,7 +198,7 @@ class LibraryItem { | |||||||
|         this.libraryFiles = payload.libraryFiles.map(lf => lf.clone()) |         this.libraryFiles = payload.libraryFiles.map(lf => lf.clone()) | ||||||
| 
 | 
 | ||||||
|         // Use first image library file as cover
 |         // Use first image library file as cover
 | ||||||
|         var firstImageFile = this.libraryFiles.find(lf => lf.fileType === 'image') |         const firstImageFile = this.libraryFiles.find(lf => lf.fileType === 'image') | ||||||
|         if (firstImageFile) this.media.coverPath = firstImageFile.metadata.path |         if (firstImageFile) this.media.coverPath = firstImageFile.metadata.path | ||||||
|       } else if (this[key] !== undefined && key !== 'media') { |       } else if (this[key] !== undefined && key !== 'media') { | ||||||
|         this[key] = payload[key] |         this[key] = payload[key] | ||||||
| @ -214,8 +214,8 @@ class LibraryItem { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   update(payload) { |   update(payload) { | ||||||
|     var json = this.toJSON() |     const json = this.toJSON() | ||||||
|     var hasUpdates = false |     let hasUpdates = false | ||||||
|     for (const key in json) { |     for (const key in json) { | ||||||
|       if (payload[key] !== undefined) { |       if (payload[key] !== undefined) { | ||||||
|         if (key === 'media') { |         if (key === 'media') { | ||||||
| @ -259,10 +259,10 @@ class LibraryItem { | |||||||
|   // Returns null if file not found, true if file was updated, false if up to date
 |   // Returns null if file not found, true if file was updated, false if up to date
 | ||||||
|   //  updates existing LibraryFile, AudioFile, EBookFile's
 |   //  updates existing LibraryFile, AudioFile, EBookFile's
 | ||||||
|   checkFileFound(fileFound) { |   checkFileFound(fileFound) { | ||||||
|     var hasUpdated = false |     let hasUpdated = false | ||||||
| 
 | 
 | ||||||
|     var existingFile = this.libraryFiles.find(lf => lf.ino === fileFound.ino) |     let existingFile = this.libraryFiles.find(lf => lf.ino === fileFound.ino) | ||||||
|     var mediaFile = null |     let mediaFile = null | ||||||
|     if (!existingFile) { |     if (!existingFile) { | ||||||
|       existingFile = this.libraryFiles.find(lf => lf.metadata.path === fileFound.metadata.path) |       existingFile = this.libraryFiles.find(lf => lf.metadata.path === fileFound.metadata.path) | ||||||
|       if (existingFile) { |       if (existingFile) { | ||||||
| @ -315,7 +315,7 @@ class LibraryItem { | |||||||
| 
 | 
 | ||||||
|   // Data pulled from scandir during a scan, check it with current data
 |   // Data pulled from scandir during a scan, check it with current data
 | ||||||
|   checkScanData(dataFound) { |   checkScanData(dataFound) { | ||||||
|     var hasUpdated = false |     let hasUpdated = false | ||||||
| 
 | 
 | ||||||
|     if (this.isMissing) { |     if (this.isMissing) { | ||||||
|       // Item no longer missing
 |       // Item no longer missing
 | ||||||
| @ -498,7 +498,7 @@ class LibraryItem { | |||||||
| 
 | 
 | ||||||
|   removeLibraryFile(ino) { |   removeLibraryFile(ino) { | ||||||
|     if (!ino) return false |     if (!ino) return false | ||||||
|     var libraryFile = this.libraryFiles.find(lf => lf.ino === ino) |     const libraryFile = this.libraryFiles.find(lf => lf.ino === ino) | ||||||
|     if (libraryFile) { |     if (libraryFile) { | ||||||
|       this.libraryFiles = this.libraryFiles.filter(lf => lf.ino !== ino) |       this.libraryFiles = this.libraryFiles.filter(lf => lf.ino !== ino) | ||||||
|       this.updatedAt = Date.now() |       this.updatedAt = Date.now() | ||||||
|  | |||||||
| @ -40,7 +40,7 @@ class Author { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   toJSONExpanded(numBooks = 0) { |   toJSONExpanded(numBooks = 0) { | ||||||
|     var json = this.toJSON() |     const json = this.toJSON() | ||||||
|     json.numBooks = numBooks |     json.numBooks = numBooks | ||||||
|     return json |     return json | ||||||
|   } |   } | ||||||
| @ -63,11 +63,11 @@ class Author { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   update(payload) { |   update(payload) { | ||||||
|     var json = this.toJSON() |     const json = this.toJSON() | ||||||
|     delete json.id |     delete json.id | ||||||
|     delete json.addedAt |     delete json.addedAt | ||||||
|     delete json.updatedAt |     delete json.updatedAt | ||||||
|     var hasUpdates = false |     let hasUpdates = false | ||||||
|     for (const key in json) { |     for (const key in json) { | ||||||
|       if (payload[key] !== undefined && json[key] != payload[key]) { |       if (payload[key] !== undefined && json[key] != payload[key]) { | ||||||
|         this[key] = payload[key] |         this[key] = payload[key] | ||||||
|  | |||||||
| @ -92,7 +92,7 @@ class PodcastEpisode { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   get audioTrack() { |   get audioTrack() { | ||||||
|     var audioTrack = new AudioTrack() |     const audioTrack = new AudioTrack() | ||||||
|     audioTrack.setData(this.libraryItemId, this.audioFile, 0) |     audioTrack.setData(this.libraryItemId, this.audioFile, 0) | ||||||
|     return audioTrack |     return audioTrack | ||||||
|   } |   } | ||||||
| @ -133,7 +133,7 @@ class PodcastEpisode { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   update(payload) { |   update(payload) { | ||||||
|     var hasUpdates = false |     let hasUpdates = false | ||||||
|     for (const key in this.toJSON()) { |     for (const key in this.toJSON()) { | ||||||
|       if (payload[key] != undefined && payload[key] != this[key]) { |       if (payload[key] != undefined && payload[key] != this[key]) { | ||||||
|         this[key] = payload[key] |         this[key] = payload[key] | ||||||
|  | |||||||
| @ -50,7 +50,7 @@ class Series { | |||||||
|   update(series) { |   update(series) { | ||||||
|     if (!series) return false |     if (!series) return false | ||||||
|     const keysToUpdate = ['name', 'description'] |     const keysToUpdate = ['name', 'description'] | ||||||
|     var hasUpdated = false |     let hasUpdated = false | ||||||
|     for (const key of keysToUpdate) { |     for (const key of keysToUpdate) { | ||||||
|       if (series[key] !== undefined && series[key] !== this[key]) { |       if (series[key] !== undefined && series[key] !== this[key]) { | ||||||
|         this[key] = series[key] |         this[key] = series[key] | ||||||
|  | |||||||
| @ -102,7 +102,7 @@ class AudioFile { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   get mimeType() { |   get mimeType() { | ||||||
|     var format = this.metadata.format.toUpperCase() |     const format = this.metadata.format.toUpperCase() | ||||||
|     if (AudioMimeType[format]) { |     if (AudioMimeType[format]) { | ||||||
|       return AudioMimeType[format] |       return AudioMimeType[format] | ||||||
|     } else { |     } else { | ||||||
| @ -147,7 +147,7 @@ class AudioFile { | |||||||
|       return false |       return false | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     var hasUpdates = false |     let hasUpdates = false | ||||||
|     for (let i = 0; i < updatedChapters.length; i++) { |     for (let i = 0; i < updatedChapters.length; i++) { | ||||||
|       if (JSON.stringify(updatedChapters[i]) !== JSON.stringify(this.chapters[i])) { |       if (JSON.stringify(updatedChapters[i]) !== JSON.stringify(this.chapters[i])) { | ||||||
|         hasUpdates = true |         hasUpdates = true | ||||||
| @ -163,25 +163,10 @@ class AudioFile { | |||||||
|     return new AudioFile(this.toJSON()) |     return new AudioFile(this.toJSON()) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // If the file or parent directory was renamed it is synced here
 |  | ||||||
|   syncFile(newFile) { |  | ||||||
|     // TODO: Sync file would update the file info if needed
 |  | ||||||
|     return false |  | ||||||
|     // var hasUpdates = false
 |  | ||||||
|     // var keysToSync = ['path', 'relPath', 'ext', 'filename']
 |  | ||||||
|     // keysToSync.forEach((key) => {
 |  | ||||||
|     //   if (newFile[key] !== undefined && newFile[key] !== this[key]) {
 |  | ||||||
|     //     hasUpdates = true
 |  | ||||||
|     //     this[key] = newFile[key]
 |  | ||||||
|     //   }
 |  | ||||||
|     // })
 |  | ||||||
|     // return hasUpdates
 |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   updateFromScan(scannedAudioFile) { |   updateFromScan(scannedAudioFile) { | ||||||
|     var hasUpdated = false |     let hasUpdated = false | ||||||
| 
 | 
 | ||||||
|     var newjson = scannedAudioFile.toJSON() |     const newjson = scannedAudioFile.toJSON() | ||||||
|     if (this.manuallyVerified) newjson.manuallyVerified = true |     if (this.manuallyVerified) newjson.manuallyVerified = true | ||||||
|     if (this.exclude) newjson.exclude = true |     if (this.exclude) newjson.exclude = true | ||||||
|     newjson.addedAt = this.addedAt |     newjson.addedAt = this.addedAt | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user