|
@@ -44,7 +44,7 @@ const configSchema = {
|
|
|
paths: {
|
|
paths: {
|
|
|
type: 'array',
|
|
type: 'array',
|
|
|
title: 'Output Paths',
|
|
title: 'Output Paths',
|
|
|
- description: 'Relative output paths from a finished job, normally {{$json.outputs}} from an SD.cpp Wait For Job node. A comma separated string works too',
|
|
|
|
|
|
|
+ description: 'Relative output paths from a finished job. One entry holding {{data.outputs}} is the usual way - that is the whole list from the SD.cpp Wait For Job node in front of this one. A comma separated string works too',
|
|
|
items: { type: 'string' }
|
|
items: { type: 'string' }
|
|
|
},
|
|
},
|
|
|
limit: {
|
|
limit: {
|
|
@@ -181,20 +181,25 @@ function login(server, credential, timeout) {
|
|
|
return session.token;
|
|
return session.token;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// The paths setting is a list, and the usual way to fill it is one entry
|
|
|
|
|
+// holding an expression for a job's whole outputs array - so what arrives is a
|
|
|
|
|
+// list containing a list. Flattening is not tidiness: without it the inner list
|
|
|
|
|
+// becomes one string, "a.png,b.png", and the server is asked for a file by that
|
|
|
|
|
+// name and answers 404. It only showed up once a job returned more than one
|
|
|
|
|
+// image, which is why a batch count of 1 never hit it.
|
|
|
function toPathList(value) {
|
|
function toPathList(value) {
|
|
|
if (value === undefined || value === null || value === '') {
|
|
if (value === undefined || value === null || value === '') {
|
|
|
return [];
|
|
return [];
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (Array.isArray(value)) {
|
|
if (Array.isArray(value)) {
|
|
|
- const list = [];
|
|
|
|
|
|
|
+ let list = [];
|
|
|
for (let i = 0; i < value.length; i++) {
|
|
for (let i = 0; i < value.length; i++) {
|
|
|
- const entry = String(value[i] || '').trim();
|
|
|
|
|
- if (entry) {
|
|
|
|
|
- list.push(entry);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ list = list.concat(toPathList(value[i]));
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return String(value).split(',')
|
|
return String(value).split(',')
|
|
|
.map(function (entry) { return entry.trim(); })
|
|
.map(function (entry) { return entry.trim(); })
|
|
|
.filter(function (entry) { return entry.length > 0; });
|
|
.filter(function (entry) { return entry.length > 0; });
|
|
@@ -251,7 +256,9 @@ async function execute(config, input, context) {
|
|
|
let paths = toPathList(config.paths);
|
|
let paths = toPathList(config.paths);
|
|
|
if (paths.length === 0) {
|
|
if (paths.length === 0) {
|
|
|
throw new Error('SD.cpp: no output paths were given. Pass the outputs array from a ' +
|
|
throw new Error('SD.cpp: no output paths were given. Pass the outputs array from a ' +
|
|
|
- 'finished job, such as {{$json.outputs}}');
|
|
|
|
|
|
|
+ 'finished job - {{data.outputs}} when this node follows SD.cpp Wait For Job, or ' +
|
|
|
|
|
+ '{{$node["SD.cpp Wait For Job"].outputs}} from anywhere else. Running this node on ' +
|
|
|
|
|
+ 'its own leaves it empty, because there is no job in front of it to read');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const limit = config.limit > 0 ? config.limit : 0;
|
|
const limit = config.limit > 0 ? config.limit : 0;
|