1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08: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 // already loaded
if (!this.loaded) { if (!this.loaded) {
this.extensionTemplates = [];
if (fs.existsSync(this.extensionsFolder)) {
this.extensionList = (fs this.extensionList = (fs
.readdirSync(this.extensionsFolder)) .readdirSync(this.extensionsFolder))
.filter((f): boolean => .filter((f): boolean =>
@ -47,7 +49,6 @@ export class ExtensionConfigTemplateLoader {
); );
this.extensionList.sort(); this.extensionList.sort();
this.extensionTemplates = [];
for (let i = 0; i < this.extensionList.length; ++i) { for (let i = 0; i < this.extensionList.length; ++i) {
const extFolder = this.extensionList[i]; const extFolder = this.extensionList[i];
const extPath = path.join(this.extensionsFolder, extFolder); const extPath = path.join(this.extensionsFolder, extFolder);
@ -70,6 +71,7 @@ export class ExtensionConfigTemplateLoader {
this.extensionTemplates.push({folder: extFolder}); this.extensionTemplates.push({folder: extFolder});
} }
} }
}
this.loaded = true; this.loaded = true;
} }
@ -77,8 +79,6 @@ export class ExtensionConfigTemplateLoader {
} }
private setTemplatesToConfig(config: PrivateConfigClass) { private setTemplatesToConfig(config: PrivateConfigClass) {
if (!this.extensionTemplates) { if (!this.extensionTemplates) {
return; return;
@ -100,7 +100,7 @@ export class ExtensionConfigTemplateLoader {
if (!c) { if (!c) {
c = new ServerExtensionsEntryConfig(ext.folder); c = new ServerExtensionsEntryConfig(ext.folder);
if (ext.template) { if (ext.template) {
c.configs= new ext.template() c.configs = new ext.template();
} }
config.Extensions.extensions.push(c); config.Extensions.extensions.push(c);
} }