1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Check if folder exists before listing it.

This commit is contained in:
Patrik J. Braun 2024-03-25 21:47:05 +01:00
parent 743d29b208
commit 7f65dfd1b2

View File

@ -40,6 +40,8 @@ export class ExtensionConfigTemplateLoader {
// already loaded
if (!this.loaded) {
this.extensionTemplates = [];
if (fs.existsSync(this.extensionsFolder)) {
this.extensionList = (fs
.readdirSync(this.extensionsFolder))
.filter((f): boolean =>
@ -47,7 +49,6 @@ export class ExtensionConfigTemplateLoader {
);
this.extensionList.sort();
this.extensionTemplates = [];
for (let i = 0; i < this.extensionList.length; ++i) {
const extFolder = this.extensionList[i];
const extPath = path.join(this.extensionsFolder, extFolder);
@ -70,6 +71,7 @@ export class ExtensionConfigTemplateLoader {
this.extensionTemplates.push({folder: extFolder});
}
}
}
this.loaded = true;
}
@ -77,8 +79,6 @@ export class ExtensionConfigTemplateLoader {
}
private setTemplatesToConfig(config: PrivateConfigClass) {
if (!this.extensionTemplates) {
return;
@ -100,7 +100,7 @@ export class ExtensionConfigTemplateLoader {
if (!c) {
c = new ServerExtensionsEntryConfig(ext.folder);
if (ext.template) {
c.configs= new ext.template()
c.configs = new ext.template();
}
config.Extensions.extensions.push(c);
}