dsh-dl-server 0.3.0 → 0.3.1
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/lib/queue.js +8 -2
- package/package.json +1 -1
package/lib/queue.js
CHANGED
|
@@ -606,8 +606,10 @@ export class Queue {
|
|
|
606
606
|
} catch (error) {
|
|
607
607
|
const aborted = controller.signal.aborted
|
|
608
608
|
if (aborted) {
|
|
609
|
-
// pause / cancel / close already recorded the target state
|
|
610
|
-
|
|
609
|
+
// pause / cancel / close already recorded the target state. Only park it
|
|
610
|
+
// here when nobody else transitioned the job — a resume that landed
|
|
611
|
+
// while this transfer was unwinding must not be undone.
|
|
612
|
+
if (record.state === 'running') {
|
|
611
613
|
await this.#stopAs(id, 'host_restart')
|
|
612
614
|
}
|
|
613
615
|
} else {
|
|
@@ -644,6 +646,10 @@ export class Queue {
|
|
|
644
646
|
async #stopAs(id, reason) {
|
|
645
647
|
const record = this.jobs.get(id)
|
|
646
648
|
if (!record || isTerminal(record.state)) return
|
|
649
|
+
// Only an in-flight job may be stopped. A pause already parked it, and a
|
|
650
|
+
// resume may have re-queued it while the aborted transfer was still
|
|
651
|
+
// unwinding — overwriting that would leave the job stuck in `paused`.
|
|
652
|
+
if (record.state !== 'running' && record.state !== 'queued') return
|
|
647
653
|
const stats = this.progress.get(id)
|
|
648
654
|
record.state = 'paused'
|
|
649
655
|
record.pauseReason = reason
|