Copy data on execution only if needed

This commit is contained in:
Jan Oberhauser
2019-08-01 22:55:33 +02:00
parent a8f1f9c0ba
commit 1b59d7b886
20 changed files with 182 additions and 65 deletions

View File

@@ -538,6 +538,18 @@ export class EditImage implements INodeType {
throw new Error(`The operation "${operation}" is not supported!`);
}
const newItem: INodeExecutionData = {
json: item.json,
binary: {},
};
if (item.binary !== undefined) {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Object.assign(newItem.binary, item.binary);
}
return new Promise<INodeExecutionData>((resolve, reject) => {
gmInstance
.toBuffer((error: Error, buffer: Buffer) => {
@@ -545,9 +557,9 @@ export class EditImage implements INodeType {
return reject(error);
}
item.binary![dataPropertyName as string].data = buffer.toString(BINARY_ENCODING);
newItem.binary![dataPropertyName as string].data = buffer.toString(BINARY_ENCODING);
return resolve(item);
return resolve(newItem);
});
});
}