mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Fix incorrect audiobook file paths before a scan
This commit is contained in:
parent
d63e582e56
commit
82241fd2f2
@ -157,6 +157,20 @@ class Audiobook {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scanner had a bug that was saving a file path as the audiobook path.
|
||||||
|
// audiobook path should be a directory.
|
||||||
|
// fixing this before a scan prevents audiobooks being removed and re-added
|
||||||
|
fixRelativePath(abRootPath) {
|
||||||
|
var pathExt = Path.extname(this.path)
|
||||||
|
if (pathExt) {
|
||||||
|
this.path = Path.dirname(this.path)
|
||||||
|
this.fullPath = Path.join(abRootPath, this.path)
|
||||||
|
Logger.warn('Audiobook path has extname', pathExt, 'fixed path:', this.path)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
setData(data) {
|
setData(data) {
|
||||||
this.id = (Math.trunc(Math.random() * 1000) + Date.now()).toString(36)
|
this.id = (Math.trunc(Math.random() * 1000) + Date.now()).toString(36)
|
||||||
this.path = data.path
|
this.path = data.path
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Path = require('path')
|
||||||
const Logger = require('./Logger')
|
const Logger = require('./Logger')
|
||||||
const BookFinder = require('./BookFinder')
|
const BookFinder = require('./BookFinder')
|
||||||
const Audiobook = require('./Audiobook')
|
const Audiobook = require('./Audiobook')
|
||||||
@ -20,6 +21,15 @@ class Scanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async scan() {
|
async scan() {
|
||||||
|
// TEMP - fix relative file paths
|
||||||
|
if (this.audiobooks.length) {
|
||||||
|
for (let i = 0; i < this.audiobooks.length; i++) {
|
||||||
|
if (ab.fixRelativePath(this.AudiobookPath)) {
|
||||||
|
await this.db.updateAudiobook(ab)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const scanStart = Date.now()
|
const scanStart = Date.now()
|
||||||
var audiobookDataFound = await getAllAudiobookFiles(this.AudiobookPath)
|
var audiobookDataFound = await getAllAudiobookFiles(this.AudiobookPath)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user