Compare commits
2 Commits
e6bad780ee
...
c462f6bef5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c462f6bef5 | ||
|
|
1af7f8a94d |
@ -35,6 +35,7 @@ class UploadManager extends EventEmitter {
|
|||||||
this.cancelledJobIds = new Set();
|
this.cancelledJobIds = new Set();
|
||||||
this.sessionBytes = 0;
|
this.sessionBytes = 0;
|
||||||
this.lastStartTime = {}; // hoster -> timestamp of last upload start
|
this.lastStartTime = {}; // hoster -> timestamp of last upload start
|
||||||
|
this.intervalLocks = {}; // hoster -> Promise chain for serialized interval waits
|
||||||
this.globalThrottle = null;
|
this.globalThrottle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +545,10 @@ class UploadManager extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async _waitForInterval(hoster, intervalMs, signal) {
|
_waitForInterval(hoster, intervalMs, signal) {
|
||||||
|
// Serialize interval waits per hoster so concurrent jobs queue up properly
|
||||||
|
const prev = this.intervalLocks[hoster] || Promise.resolve();
|
||||||
|
const next = prev.then(async () => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const last = this.lastStartTime[hoster] || 0;
|
const last = this.lastStartTime[hoster] || 0;
|
||||||
const elapsed = now - last;
|
const elapsed = now - last;
|
||||||
@ -552,6 +556,9 @@ class UploadManager extends EventEmitter {
|
|||||||
await this._sleep(intervalMs - elapsed, signal);
|
await this._sleep(intervalMs - elapsed, signal);
|
||||||
}
|
}
|
||||||
this.lastStartTime[hoster] = Date.now();
|
this.lastStartTime[hoster] = Date.now();
|
||||||
|
});
|
||||||
|
this.intervalLocks[hoster] = next.catch(() => {});
|
||||||
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelJobs(jobIds) {
|
cancelJobs(jobIds) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-hoster-uploader",
|
"name": "multi-hoster-uploader",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"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