Merge pull request #632 from cassieesposito/getBookDataFromDir-refactor

URGENT: Fix to serious bug
This commit is contained in:
advplyr 2022-05-24 21:33:40 -05:00 committed by GitHub
commit 97d4330cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,8 +216,9 @@ function getBookDataFromDir(folderPath, relPath, parseSubtitle = false) {
// The may contain various other pieces of metadata, these functions extract it.
var [folder, narrators] = getNarrator(folder)
if (series) { var [folder, sequence] = getSequence(folder) }
var [folder, sequence] = series ? getSequence(folder) : [folder, null]
var [folder, publishedYear] = getPublishedYear(folder)
if (parseSubtitle) { var [title, subtitle] = getSubtitle(folder) } // Subtitle can be parsed from the title if user enabled
var [title, subtitle] = parseSubtitle ? getSubtitle(folder) : [folder, null]
return {
mediaMetadata: {
@ -330,10 +331,12 @@ async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath,
var fileItems = []
if (isSingleMediaItem) { // Single media item in root of folder
fileItems = [{
fileItems = [
{
fullpath: libraryItemPath,
path: libraryItemDir // actually the relPath (only filename here)
}]
}
]
libraryItemData = {
path: libraryItemPath, // full path
relPath: libraryItemDir, // only filename
@ -366,10 +369,10 @@ async function getLibraryItemFileData(libraryMediaType, folder, libraryItemPath,
for (let i = 0; i < fileItems.length; i++) {
var fileItem = fileItems[i]
var newLibraryFile = new LibraryFile()
// fileItem.path is the relative path
// fileItem.path is the relative path
await newLibraryFile.setDataFromPath(fileItem.fullpath, fileItem.path)
libraryItem.libraryFiles.push(newLibraryFile)
}
return libraryItem
}
module.exports.getLibraryItemFileData = getLibraryItemFileData
module.exports.getLibraryItemFileData = getLibraryItemFileData