mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Unify binary-data assertion across all nodes (no-changelog) (#5624)
This commit is contained in:
committed by
GitHub
parent
01a2160b3b
commit
5eb0d52459
@@ -1,6 +1,6 @@
|
||||
import type { IExecuteFunctions } from 'n8n-core';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodeProperties,
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { deepCopy, NodeOperationError } from 'n8n-workflow';
|
||||
import { deepCopy } from 'n8n-workflow';
|
||||
import gm from 'gm';
|
||||
import { file } from 'tmp-promise';
|
||||
import { parse as pathParse } from 'path';
|
||||
@@ -1058,20 +1058,7 @@ export class EditImage implements INodeType {
|
||||
|
||||
if (operations[0].operation !== 'create') {
|
||||
// "create" generates a new image so does not require any incoming data.
|
||||
if (item.binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'Item does not contain any binary data.', {
|
||||
itemIndex,
|
||||
});
|
||||
}
|
||||
|
||||
if (item.binary[dataPropertyName] === undefined) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Item does not contain any binary data with the name "${dataPropertyName}".`,
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
|
||||
this.helpers.assertBinaryData(itemIndex, dataPropertyName);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
itemIndex,
|
||||
dataPropertyName,
|
||||
@@ -1123,20 +1110,15 @@ export class EditImage implements INodeType {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
(positionX >= 0 ? '+' : '') + positionX + (positionY >= 0 ? '+' : '') + positionY;
|
||||
|
||||
if (item.binary![operationData.dataPropertyNameComposite as string] === undefined) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Item does not contain any binary data with the name "${operationData.dataPropertyNameComposite}".`,
|
||||
{ itemIndex },
|
||||
);
|
||||
}
|
||||
const binaryPropertyName = operationData.dataPropertyNameComposite as string;
|
||||
this.helpers.assertBinaryData(itemIndex, binaryPropertyName);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
itemIndex,
|
||||
binaryPropertyName,
|
||||
);
|
||||
|
||||
const { fd, path, cleanup } = await file();
|
||||
cleanupFunctions.push(cleanup);
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
itemIndex,
|
||||
operationData.dataPropertyNameComposite as string,
|
||||
);
|
||||
await fsWriteFileAsync(fd, binaryDataBuffer);
|
||||
|
||||
if (operations[0].operation === 'create') {
|
||||
|
||||
Reference in New Issue
Block a user