Skip to content

Commit

Permalink
Update:Some logs to include library item id #3440
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Sep 22, 2024
1 parent 1dec8ae commit decde23
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion server/controllers/LibraryItemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class LibraryItemController {
const libraryId = itemsToDelete[0].libraryId
for (const libraryItem of itemsToDelete) {
const libraryItemPath = libraryItem.path
Logger.info(`[LibraryItemController] Deleting Library Item "${libraryItem.media.metadata.title}"`)
Logger.info(`[LibraryItemController] Deleting Library Item "${libraryItem.media.metadata.title}" with id "${libraryItem.id}"`)
const mediaItemIds = libraryItem.mediaType === 'podcast' ? libraryItem.media.episodes.map((ep) => ep.id) : [libraryItem.media.id]
await this.handleDeleteLibraryItem(libraryItem.mediaType, libraryItem.id, mediaItemIds)
if (hardDelete) {
Expand Down
45 changes: 23 additions & 22 deletions server/scanner/LibraryItemScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const LibraryFile = require('../objects/files/LibraryFile')
const SocketAuthority = require('../SocketAuthority')

class LibraryItemScanner {
constructor() { }
constructor() {}

/**
* Scan single library item
*
* @param {string} libraryItemId
*
* @param {string} libraryItemId
* @param {{relPath:string, path:string}} [updateLibraryItemDetails] used by watcher when item folder was renamed
* @returns {number} ScanResult
*/
Expand Down Expand Up @@ -76,8 +76,8 @@ class LibraryItemScanner {

/**
* Remove empty authors and series
* @param {string} libraryId
* @param {ScanLogger} scanLogger
* @param {string} libraryId
* @param {ScanLogger} scanLogger
* @returns {Promise}
*/
async checkAuthorsAndSeriesRemovedFromBooks(libraryId, scanLogger) {
Expand All @@ -90,11 +90,11 @@ class LibraryItemScanner {
}

/**
*
* @param {string} libraryItemPath
* @param {import('../models/Library')} library
* @param {import('../models/LibraryFolder')} folder
* @param {boolean} isSingleMediaItem
*
* @param {string} libraryItemPath
* @param {import('../models/Library')} library
* @param {import('../models/LibraryFolder')} folder
* @param {boolean} isSingleMediaItem
* @returns {Promise<LibraryItemScanData>}
*/
async getLibraryItemScanData(libraryItemPath, library, folder, isSingleMediaItem) {
Expand All @@ -105,7 +105,8 @@ class LibraryItemScanner {

let fileItems = []

if (isSingleMediaItem) { // Single media item in root of folder
if (isSingleMediaItem) {
// Single media item in root of folder
fileItems = [
{
fullpath: libraryItemPath,
Expand Down Expand Up @@ -151,9 +152,9 @@ class LibraryItemScanner {
}

/**
*
* @param {import('../models/LibraryItem')} existingLibraryItem
* @param {LibraryItemScanData} libraryItemData
*
* @param {import('../models/LibraryItem')} existingLibraryItem
* @param {LibraryItemScanData} libraryItemData
* @param {import('../models/Library').LibrarySettingsObject} librarySettings
* @param {LibraryScan} libraryScan
* @returns {Promise<{libraryItem:LibraryItem, wasUpdated:boolean}>}
Expand All @@ -167,8 +168,8 @@ class LibraryItemScanner {
}

/**
*
* @param {LibraryItemScanData} libraryItemData
*
* @param {LibraryItemScanData} libraryItemData
* @param {import('../models/Library').LibrarySettingsObject} librarySettings
* @param {LibraryScan} libraryScan
* @returns {Promise<LibraryItem>}
Expand All @@ -181,17 +182,17 @@ class LibraryItemScanner {
newLibraryItem = await PodcastScanner.scanNewPodcastLibraryItem(libraryItemData, librarySettings, libraryScan)
}
if (newLibraryItem) {
libraryScan.addLog(LogLevel.INFO, `Created new library item "${newLibraryItem.relPath}"`)
libraryScan.addLog(LogLevel.INFO, `Created new library item "${newLibraryItem.relPath}" with id "${newLibraryItem.id}"`)
}
return newLibraryItem
}

/**
* Scan library item folder coming from Watcher
* @param {string} libraryItemPath
* @param {import('../models/Library')} library
* @param {import('../models/LibraryFolder')} folder
* @param {boolean} isSingleMediaItem
* @param {string} libraryItemPath
* @param {import('../models/Library')} library
* @param {import('../models/LibraryFolder')} folder
* @param {boolean} isSingleMediaItem
* @returns {Promise<LibraryItem>} ScanResult
*/
async scanPotentialNewLibraryItem(libraryItemPath, library, folder, isSingleMediaItem) {
Expand All @@ -204,4 +205,4 @@ class LibraryItemScanner {
return this.scanNewLibraryItem(libraryItemScanData, library.settings, scanLogger)
}
}
module.exports = new LibraryItemScanner()
module.exports = new LibraryItemScanner()
2 changes: 1 addition & 1 deletion server/scanner/LibraryScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ class LibraryScanner {
}
}
// Scan library item for updates
Logger.debug(`[LibraryScanner] Folder update for relative path "${itemDir}" is in library item "${existingLibraryItem.media.metadata.title}" - scan for updates`)
Logger.debug(`[LibraryScanner] Folder update for relative path "${itemDir}" is in library item "${existingLibraryItem.media.metadata.title}" with id "${existingLibraryItem.id}" - scan for updates`)
itemGroupingResults[itemDir] = await LibraryItemScanner.scanLibraryItem(existingLibraryItem.id, updatedLibraryItemDetails)
continue
} else if (library.settings.audiobooksOnly && !hasAudioFiles(fileUpdateGroup, itemDir)) {
Expand Down

0 comments on commit decde23

Please sign in to comment.