Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate scheduled tasks based on command line #95

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/backend/executor/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,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