mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-04 02:05:06 +02:00
Fix:Relative file path for single book scans, Change:Route names & refactor api
This commit is contained in:
parent
2194d55cc0
commit
66a490365a
41 changed files with 1057 additions and 986 deletions
|
@ -89,10 +89,17 @@ function setFileOwner(path, uid, gid) {
|
|||
}
|
||||
module.exports.setFileOwner = setFileOwner
|
||||
|
||||
async function recurseFiles(path) {
|
||||
async function recurseFiles(path, relPathToReplace = null) {
|
||||
path = path.replace(/\\/g, '/')
|
||||
if (!path.endsWith('/')) path = path + '/'
|
||||
|
||||
if (relPathToReplace) {
|
||||
relPathToReplace = relPathToReplace.replace(/\\/g, '/')
|
||||
if (!relPathToReplace.endsWith('/')) relPathToReplace += '/'
|
||||
} else {
|
||||
relPathToReplace = path
|
||||
}
|
||||
|
||||
const options = {
|
||||
mode: rra.LIST,
|
||||
recursive: true,
|
||||
|
@ -116,7 +123,7 @@ async function recurseFiles(path) {
|
|||
}
|
||||
|
||||
// Ignore any file if a directory or the filename starts with "."
|
||||
var relpath = item.fullname.replace(path, '')
|
||||
var relpath = item.fullname.replace(relPathToReplace, '')
|
||||
var pathStartsWithPeriod = relpath.split('/').find(p => p.startsWith('.'))
|
||||
if (pathStartsWithPeriod) {
|
||||
Logger.debug(`[fileUtils] Ignoring path has . "${relpath}"`)
|
||||
|
@ -126,9 +133,9 @@ async function recurseFiles(path) {
|
|||
return true
|
||||
}).map((item) => ({
|
||||
name: item.name,
|
||||
path: item.fullname.replace(path, ''),
|
||||
path: item.fullname.replace(relPathToReplace, ''),
|
||||
dirpath: item.path,
|
||||
reldirpath: item.path.replace(path, ''),
|
||||
reldirpath: item.path.replace(relPathToReplace, ''),
|
||||
fullpath: item.fullname,
|
||||
extension: item.extension,
|
||||
deep: item.deep
|
||||
|
|
|
@ -267,7 +267,7 @@ function getAudiobookDataFromDir(folderPath, dir, parseSubtitle = false) {
|
|||
async function getAudiobookFileData(folder, audiobookPath, serverSettings = {}) {
|
||||
var parseSubtitle = !!serverSettings.scannerParseSubtitle
|
||||
|
||||
var fileItems = await recurseFiles(audiobookPath)
|
||||
var fileItems = await recurseFiles(audiobookPath, folder.fullPath)
|
||||
|
||||
audiobookPath = audiobookPath.replace(/\\/g, '/')
|
||||
var folderFullPath = folder.fullPath.replace(/\\/g, '/')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue