@xiaohhhh1/canvas-agent 0.4.85 → 0.4.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/workflow/manager.js +24 -9
- package/package.json +1 -1
package/dist/workflow/manager.js
CHANGED
|
@@ -1134,18 +1134,33 @@ export class WorkflowManager {
|
|
|
1134
1134
|
record.market = batch.market;
|
|
1135
1135
|
const deliveries = batch.deliveries || [];
|
|
1136
1136
|
let cursor = 0;
|
|
1137
|
+
let failed = false;
|
|
1138
|
+
let firstFailure;
|
|
1137
1139
|
const workers = Array.from({ length: Math.min(4, deliveries.length) }, async () => {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
record.downloadedOrdinals.
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1140
|
+
try {
|
|
1141
|
+
while (!failed && cursor < deliveries.length) {
|
|
1142
|
+
const delivery = deliveries[cursor++];
|
|
1143
|
+
await this.saveDelivery(batch, delivery);
|
|
1144
|
+
if (!record.downloadedOrdinals.includes(delivery.ordinal))
|
|
1145
|
+
record.downloadedOrdinals.push(delivery.ordinal);
|
|
1146
|
+
record.message = `正在保存本批全部成片:${record.downloadedOrdinals.length}/${deliveries.length}`;
|
|
1147
|
+
record.updatedAt = now();
|
|
1148
|
+
this.save();
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
catch (error) {
|
|
1152
|
+
if (!failed) {
|
|
1153
|
+
failed = true;
|
|
1154
|
+
firstFailure = error;
|
|
1155
|
+
}
|
|
1156
|
+
throw error;
|
|
1146
1157
|
}
|
|
1147
1158
|
});
|
|
1148
|
-
|
|
1159
|
+
// A retry must not unlink a .part file still owned by an earlier
|
|
1160
|
+
// writer. Stop admission on failure and drain all admitted writers.
|
|
1161
|
+
await Promise.allSettled(workers);
|
|
1162
|
+
if (failed)
|
|
1163
|
+
throw firstFailure;
|
|
1149
1164
|
record.downloadedOrdinals.sort((a, b) => a - b);
|
|
1150
1165
|
const finished = ["completed", "cancelled", "failed"].includes(batch.status);
|
|
1151
1166
|
record.status = finished && record.downloadedOrdinals.length >= (batch.deliveries?.length || 0) ? "complete" : "waiting";
|