Skip to content

Commit

Permalink
Merge pull request #95 from Discookie/ericsson/fix-duplicate-tasks
Browse files Browse the repository at this point in the history
Deduplicate scheduled tasks based on command line
  • Loading branch information
csordasmarton authored Mar 7, 2022
2 parents fc426e2 + ca49767 commit 816c665
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/backend/executor/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,24 @@ export class ExecutorManager implements Disposable {
const name = process.processParameters.processType!;
let namedQueue = this.queue.get(name) ?? [];

// When adding the same process as the currently running one, assume that its underlying data was changed,
// and kill the currently active process
if (this.activeProcess?.commandLine === process.commandLine) {
this.killProcess();
}

// The exact same task with the exact same commandline won't be added twice
if (namedQueue.some((queueItem) => queueItem.commandLine === process.commandLine)) {
// In Prepend mode, this means removing and re-adding to move the task to the front of the queue
if (method === 'prepend') {
namedQueue = namedQueue.filter((queueItem) => queueItem.commandLine !== process.commandLine);
} else {
// Otherwise, keep the process in the queue as is, to preserve its position
this.startNextProcess();
return;
}
}

switch (method) {
case 'replace':
namedQueue = [process];
Expand Down

0 comments on commit 816c665

Please sign in to comment.