2021-12-26 18:25:07 +01:00
|
|
|
const Logger = require('../Logger')
|
2021-12-27 17:51:19 +01:00
|
|
|
const Path = require('path')
|
2021-12-26 18:25:07 +01:00
|
|
|
|
|
|
|
class FileSystemController {
|
|
|
|
constructor() { }
|
|
|
|
|
|
|
|
async getPaths(req, res) {
|
|
|
|
var excludedDirs = ['node_modules', 'client', 'server', '.git', 'static', 'build', 'dist', 'metadata', 'config', 'sys', 'proc'].map(dirname => {
|
|
|
|
return Path.sep + dirname
|
|
|
|
})
|
|
|
|
|
|
|
|
// Do not include existing mapped library paths in response
|
|
|
|
this.db.libraries.forEach(lib => {
|
|
|
|
lib.folders.forEach((folder) => {
|
|
|
|
var dir = folder.fullPath
|
|
|
|
if (dir.includes(global.appRoot)) dir = dir.replace(global.appRoot, '')
|
|
|
|
excludedDirs.push(dir)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Logger.debug(`[Server] get file system paths, excluded: ${excludedDirs.join(', ')}`)
|
2022-11-29 18:55:22 +01:00
|
|
|
res.json({
|
|
|
|
directories: await this.getDirectories(global.appRoot, '/', excludedDirs)
|
|
|
|
})
|
2021-12-26 18:25:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = new FileSystemController()
|