Fixed a parsing bug relative to paths

This commit is contained in:
Christian Risi 2025-07-04 09:00:53 +00:00
parent 7f5d5ba1b1
commit 15f38a3f62

View File

@ -24,23 +24,28 @@ export class EndpointBrokerManagerFS {
} }
public static async init() { public static async init() {
if (EndpointBrokerManagerFS.ready) { if (EndpointBrokerManagerFS.ready) {
// UGLY: be specific // UGLY: be specific
throw new Error("Broker already initialized") throw new Error("Broker already initialized")
} }
const configurations = (await listFiles(NGINX_TRACKED, true)).filter( async (path) => { const candidateConfigurations = (await listFiles(NGINX_TRACKED, true))
if (await isDir(path)) { const configurations: string[] = []
return false
for (const candidatePath of candidateConfigurations) {
if (await isDir(candidatePath)) {
continue
} }
if (!path.endsWith(".conf")) { if (!candidatePath.endsWith(".conf")) {
return false continue
} }
return true configurations.push(candidatePath)
}) }
for (const confPath of configurations) { for (const confPath of configurations) {
const file = await loadFile(confPath) const file = await loadFile(confPath)
@ -66,7 +71,7 @@ export class EndpointBrokerManagerFS {
) )
} }
// TODO: Initialize a file watcher // TODO: Initialize a file watcher
EndpointBrokerManagerFS.watcher = EndpointBrokerManagerFS.watchNginxDirectory() EndpointBrokerManagerFS.watcher = EndpointBrokerManagerFS.watchNginxDirectory()
@ -81,7 +86,7 @@ export class EndpointBrokerManagerFS {
const REAL_PATH = `${NGINX_TRACKED}/${endpoint.path}` const REAL_PATH = `${NGINX_TRACKED}/${endpoint.path}`
if (await doesFileExist(REAL_PATH) ) { if (await doesFileExist(REAL_PATH)) {
// UGLY: be specific // UGLY: be specific
throw new Error("File already existant") throw new Error("File already existant")
} }
@ -263,7 +268,7 @@ export class EndpointBrokerManagerFS {
// UGLY: more specific // UGLY: more specific
throw new Error("This path is non existant") throw new Error("This path is non existant")
} }