Compare commits
2 Commits
3c84679df1
...
ad9299e74c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad9299e74c | ||
|
|
ff6f7f8612 |
@ -136,6 +136,7 @@ class UploadManager extends EventEmitter {
|
|||||||
const batchId = `batch-${Date.now()}`;
|
const batchId = `batch-${Date.now()}`;
|
||||||
const results = new Map(); // filePath -> { name, size, results: [] }
|
const results = new Map(); // filePath -> { name, size, results: [] }
|
||||||
this._batchResults = results;
|
this._batchResults = results;
|
||||||
|
this._additionalPromises = []; // Track jobs added mid-batch via addJobs()
|
||||||
|
|
||||||
for (const task of tasks) {
|
for (const task of tasks) {
|
||||||
const fileName = path.basename(task.file);
|
const fileName = path.basename(task.file);
|
||||||
@ -150,6 +151,11 @@ class UploadManager extends EventEmitter {
|
|||||||
|
|
||||||
const promises = tasks.map((task) => this._runJob(task, results, signal));
|
const promises = tasks.map((task) => this._runJob(task, results, signal));
|
||||||
await Promise.allSettled(promises);
|
await Promise.allSettled(promises);
|
||||||
|
// Wait for any jobs added mid-batch via addJobs()
|
||||||
|
while (this._additionalPromises.length > 0) {
|
||||||
|
const batch = this._additionalPromises.splice(0);
|
||||||
|
await Promise.allSettled(batch);
|
||||||
|
}
|
||||||
|
|
||||||
this._stopStatsTimer();
|
this._stopStatsTimer();
|
||||||
this.running = false;
|
this.running = false;
|
||||||
@ -703,9 +709,9 @@ class UploadManager extends EventEmitter {
|
|||||||
results.set(task.file, { name: fileName, size, results: [] });
|
results.set(task.file, { name: fileName, size, results: [] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start each new job — they'll acquire semaphores and run
|
// Start each new job and track promises so batch-done waits for them
|
||||||
for (const task of tasks) {
|
for (const task of tasks) {
|
||||||
this._runJob(task, results, signal);
|
this._additionalPromises.push(this._runJob(task, results, signal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-hoster-uploader",
|
"name": "multi-hoster-uploader",
|
||||||
"version": "2.5.6",
|
"version": "2.5.7",
|
||||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user