Update:Library folder browser to also work for debian and windows

This commit is contained in:
advplyr 2024-01-03 16:23:17 -06:00
parent 8c6a2ac5dd
commit 9f909b0d85
5 changed files with 184 additions and 79 deletions

View file

@ -320,35 +320,6 @@ class ApiRouter {
this.router.get('/stats/year/:year', MiscController.getAdminStatsForYear.bind(this))
}
async getDirectories(dir, relpath, excludedDirs, level = 0) {
try {
const paths = await fs.readdir(dir)
let dirs = await Promise.all(paths.map(async dirname => {
const fullPath = Path.join(dir, dirname)
const path = Path.join(relpath, dirname)
const isDir = (await fs.lstat(fullPath)).isDirectory()
if (isDir && !excludedDirs.includes(path) && dirname !== 'node_modules') {
return {
path,
dirname,
fullPath,
level,
dirs: level < 4 ? (await this.getDirectories(fullPath, path, excludedDirs, level + 1)) : []
}
} else {
return false
}
}))
dirs = dirs.filter(d => d)
return dirs
} catch (error) {
Logger.error('Failed to readdir', dir, error)
return []
}
}
//
// Helper Methods
//