mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-02-10 00:18:06 +01:00
update approach for ensuring download directory always exists
This commit is contained in:
parent
c606a41314
commit
853513b926
@ -139,7 +139,8 @@ class Server {
|
|||||||
await this.checkUserMediaProgress() // Remove invalid user item progress
|
await this.checkUserMediaProgress() // Remove invalid user item progress
|
||||||
await this.purgeMetadata() // Remove metadata folders without library item
|
await this.purgeMetadata() // Remove metadata folders without library item
|
||||||
await this.cacheManager.ensureCachePaths()
|
await this.cacheManager.ensureCachePaths()
|
||||||
|
await this.abMergeManager.ensureDownloadDirPath()
|
||||||
|
|
||||||
await this.backupManager.init()
|
await this.backupManager.init()
|
||||||
await this.logManager.init()
|
await this.logManager.init()
|
||||||
this.podcastManager.init()
|
this.podcastManager.init()
|
||||||
|
@ -16,11 +16,28 @@ class AbMergeManager {
|
|||||||
this.clientEmitter = clientEmitter
|
this.clientEmitter = clientEmitter
|
||||||
|
|
||||||
this.downloadDirPath = Path.join(global.MetadataPath, 'downloads')
|
this.downloadDirPath = Path.join(global.MetadataPath, 'downloads')
|
||||||
|
this.downloadDirPathExist = false
|
||||||
|
|
||||||
this.pendingDownloads = []
|
this.pendingDownloads = []
|
||||||
this.downloads = []
|
this.downloads = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async ensureDownloadDirPath() { // Creates download path if necessary and sets owner and permissions
|
||||||
|
if (this.downloadDirPathExist) return
|
||||||
|
|
||||||
|
var pathCreated = false
|
||||||
|
if (!(await fs.pathExists(this.downloadDirPath))) {
|
||||||
|
await fs.mkdir(this.downloadDirPath)
|
||||||
|
pathCreated = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathCreated) {
|
||||||
|
await filePerms.setDefault(this.downloadDirPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.downloadDirPathExist = true
|
||||||
|
}
|
||||||
|
|
||||||
getDownload(downloadId) {
|
getDownload(downloadId) {
|
||||||
return this.downloads.find(d => d.id === downloadId)
|
return this.downloads.find(d => d.id === downloadId)
|
||||||
}
|
}
|
||||||
@ -48,7 +65,7 @@ class AbMergeManager {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}z
|
||||||
|
|
||||||
async startAudiobookMerge(user, libraryItem) {
|
async startAudiobookMerge(user, libraryItem) {
|
||||||
var downloadId = getId('abmerge')
|
var downloadId = getId('abmerge')
|
||||||
@ -73,7 +90,8 @@ class AbMergeManager {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.ensureDir(download.dirpath)
|
await fs.mkdir(download.dirpath)
|
||||||
|
Logger.error(`[AbMergeManager] Failed to make directory ${download.dirpath}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error(`[AbMergeManager] Failed to make directory ${download.dirpath}`)
|
Logger.error(`[AbMergeManager] Failed to make directory ${download.dirpath}`)
|
||||||
Logger.debug(`[AbMergeManager] Make directory error: ${error}`)
|
Logger.debug(`[AbMergeManager] Make directory error: ${error}`)
|
||||||
|
@ -19,17 +19,17 @@ class CacheManager {
|
|||||||
|
|
||||||
var pathsCreated = false
|
var pathsCreated = false
|
||||||
if (!(await fs.pathExists(this.CachePath))) {
|
if (!(await fs.pathExists(this.CachePath))) {
|
||||||
await fs.ensureDir(this.CachePath)
|
await fs.mkdir(this.CachePath)
|
||||||
pathsCreated = true
|
pathsCreated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await fs.pathExists(this.CoverCachePath))) {
|
if (!(await fs.pathExists(this.CoverCachePath))) {
|
||||||
await fs.ensureDir(this.CoverCachePath)
|
await fs.mkdir(this.CoverCachePath)
|
||||||
pathsCreated = true
|
pathsCreated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await fs.pathExists(this.ImageCachePath))) {
|
if (!(await fs.pathExists(this.ImageCachePath))) {
|
||||||
await fs.ensureDir(this.ImageCachePath)
|
await fs.mkdir(this.ImageCachePath)
|
||||||
pathsCreated = true
|
pathsCreated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user