mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
fix(core): Stop copying icons to cache (#5419)
Fixes - https://github.com/n8n-io/n8n/issues/4973 - https://github.com/n8n-io/n8n/issues/5274 - https://community.n8n.io/t/starting-n8n-fails-with-ebusy-error/21243 - https://community.n8n.io/t/problem-executing-workflow-ebusy-resource-busy-or-locked-copyfile/21280 Replaces - https://github.com/n8n-io/n8n/pull/5052 - https://github.com/n8n-io/n8n/pull/5401
This commit is contained in:
committed by
GitHub
parent
1f924e3c3d
commit
f23fb92696
@@ -48,19 +48,21 @@ export abstract class DirectoryLoader {
|
||||
protected readonly includeNodes: string[] = [],
|
||||
) {}
|
||||
|
||||
abstract packageName: string;
|
||||
abstract loadAll(): Promise<void>;
|
||||
|
||||
protected resolvePath(file: string) {
|
||||
return path.resolve(this.directory, file);
|
||||
}
|
||||
|
||||
protected loadNodeFromFile(packageName: string, nodeName: string, filePath: string) {
|
||||
protected loadNodeFromFile(nodeName: string, filePath: string) {
|
||||
let tempNode: INodeType | IVersionedNodeType;
|
||||
let nodeVersion = 1;
|
||||
const isCustom = this.packageName === 'CUSTOM';
|
||||
|
||||
try {
|
||||
tempNode = loadClassInIsolation(filePath, nodeName);
|
||||
this.addCodex({ node: tempNode, filePath, isCustom: packageName === 'CUSTOM' });
|
||||
this.addCodex({ node: tempNode, filePath, isCustom });
|
||||
} catch (error) {
|
||||
Logger.error(
|
||||
`Error loading node "${nodeName}" from: "${filePath}" - ${(error as Error).message}`,
|
||||
@@ -68,7 +70,7 @@ export abstract class DirectoryLoader {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const fullNodeName = `${packageName}.${tempNode.description.name}`;
|
||||
const fullNodeName = `${this.packageName}.${tempNode.description.name}`;
|
||||
|
||||
if (this.includeNodes.length && !this.includeNodes.includes(fullNodeName)) {
|
||||
return;
|
||||
@@ -88,12 +90,12 @@ export abstract class DirectoryLoader {
|
||||
}
|
||||
|
||||
const currentVersionNode = tempNode.nodeVersions[tempNode.currentVersion];
|
||||
this.addCodex({ node: currentVersionNode, filePath, isCustom: packageName === 'CUSTOM' });
|
||||
this.addCodex({ node: currentVersionNode, filePath, isCustom });
|
||||
nodeVersion = tempNode.currentVersion;
|
||||
|
||||
if (currentVersionNode.hasOwnProperty('executeSingle')) {
|
||||
Logger.warn(
|
||||
`"executeSingle" will get deprecated soon. Please update the code of node "${packageName}.${nodeName}" to use "execute" instead!`,
|
||||
`"executeSingle" will get deprecated soon. Please update the code of node "${this.packageName}.${nodeName}" to use "execute" instead!`,
|
||||
{ filePath },
|
||||
);
|
||||
}
|
||||
@@ -236,7 +238,8 @@ export abstract class DirectoryLoader {
|
||||
if (obj.icon?.startsWith('file:')) {
|
||||
const iconPath = path.join(path.dirname(filePath), obj.icon.substring(5));
|
||||
const relativePath = path.relative(this.directory, iconPath);
|
||||
obj.icon = `file:${relativePath}`;
|
||||
obj.iconUrl = `icons/${this.packageName}/${relativePath}`;
|
||||
delete obj.icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,6 +249,8 @@ export abstract class DirectoryLoader {
|
||||
* e.g. `~/.n8n/custom`
|
||||
*/
|
||||
export class CustomDirectoryLoader extends DirectoryLoader {
|
||||
packageName = 'CUSTOM';
|
||||
|
||||
override async loadAll() {
|
||||
const filePaths = await glob('**/*.@(node|credentials).js', {
|
||||
cwd: this.directory,
|
||||
@@ -256,7 +261,7 @@ export class CustomDirectoryLoader extends DirectoryLoader {
|
||||
const [fileName, type] = path.parse(filePath).name.split('.');
|
||||
|
||||
if (type === 'node') {
|
||||
this.loadNodeFromFile('CUSTOM', fileName, filePath);
|
||||
this.loadNodeFromFile(fileName, filePath);
|
||||
} else if (type === 'credentials') {
|
||||
this.loadCredentialFromFile(fileName, filePath);
|
||||
}
|
||||
@@ -300,7 +305,7 @@ export class PackageDirectoryLoader extends DirectoryLoader {
|
||||
const filePath = this.resolvePath(node);
|
||||
const [nodeName] = path.parse(node).name.split('.');
|
||||
|
||||
this.loadNodeFromFile(this.packageName, nodeName, filePath);
|
||||
this.loadNodeFromFile(nodeName, filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user