mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Update LibraryItem debug logs to show objects and display libraryFiles changes differently
This commit is contained in:
parent
f1582177e1
commit
bbf214fa4c
@ -1,3 +1,4 @@
|
|||||||
|
const util = require('util')
|
||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
const { DataTypes, Model } = require('sequelize')
|
const { DataTypes, Model } = require('sequelize')
|
||||||
const fsExtra = require('../libs/fsExtra')
|
const fsExtra = require('../libs/fsExtra')
|
||||||
@ -302,7 +303,7 @@ class LibraryItem extends Model {
|
|||||||
if (existingValue instanceof Date) existingValue = existingValue.valueOf()
|
if (existingValue instanceof Date) existingValue = existingValue.valueOf()
|
||||||
|
|
||||||
if (!areEquivalent(updatedEpisodeCleaned[key], existingValue, true)) {
|
if (!areEquivalent(updatedEpisodeCleaned[key], existingValue, true)) {
|
||||||
Logger.debug(`[LibraryItem] "${libraryItemExpanded.media.title}" episode "${existingEpisodeMatch.title}" ${key} was updated from "${existingValue}" to "${updatedEpisodeCleaned[key]}"`)
|
Logger.debug(util.format(`[LibraryItem] "${libraryItemExpanded.media.title}" episode "${existingEpisodeMatch.title}" ${key} was updated from %j to %j`, existingValue, updatedEpisodeCleaned[key]))
|
||||||
episodeHasUpdates = true
|
episodeHasUpdates = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +384,23 @@ class LibraryItem extends Model {
|
|||||||
if (existingValue instanceof Date) existingValue = existingValue.valueOf()
|
if (existingValue instanceof Date) existingValue = existingValue.valueOf()
|
||||||
|
|
||||||
if (!areEquivalent(updatedLibraryItem[key], existingValue, true)) {
|
if (!areEquivalent(updatedLibraryItem[key], existingValue, true)) {
|
||||||
Logger.debug(`[LibraryItem] "${libraryItemExpanded.media.title}" ${key} updated from ${existingValue} to ${updatedLibraryItem[key]}`)
|
if (key === 'libraryFiles') {
|
||||||
|
// Handle logging of libraryFiles separately because the object is large (should be addressed when migrating off the old library item model)
|
||||||
|
const libraryFilesRemoved = libraryItemExpanded.libraryFiles.filter((lf) => !updatedLibraryItem.libraryFiles.some((ulf) => ulf.ino === lf.ino))
|
||||||
|
if (libraryFilesRemoved.length) {
|
||||||
|
Logger.debug(`[LibraryItem] "${libraryItemExpanded.media.title}" library files removed: ${libraryFilesRemoved.map((lf) => lf.metadata.path).join(', ')}`)
|
||||||
|
}
|
||||||
|
const libraryFilesAdded = updatedLibraryItem.libraryFiles.filter((ulf) => !libraryItemExpanded.libraryFiles.some((lf) => lf.ino === ulf.ino))
|
||||||
|
if (libraryFilesAdded.length) {
|
||||||
|
Logger.debug(`[LibraryItem] "${libraryItemExpanded.media.title}" library files added: ${libraryFilesAdded.map((lf) => lf.metadata.path).join(', ')}`)
|
||||||
|
}
|
||||||
|
if (!libraryFilesRemoved.length && !libraryFilesAdded.length) {
|
||||||
|
Logger.debug(`[LibraryItem] "${libraryItemExpanded.media.title}" library files updated`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.debug(util.format(`[LibraryItem] "${libraryItemExpanded.media.title}" ${key} updated from %j to %j`, existingValue, updatedLibraryItem[key]))
|
||||||
|
}
|
||||||
|
|
||||||
hasLibraryItemUpdates = true
|
hasLibraryItemUpdates = true
|
||||||
if (key === 'updatedAt') {
|
if (key === 'updatedAt') {
|
||||||
libraryItemExpanded.changed('updatedAt', true)
|
libraryItemExpanded.changed('updatedAt', true)
|
||||||
|
Loading…
Reference in New Issue
Block a user