Skip to content

Commit

Permalink
Await workspace trust in auto tasks
Browse files Browse the repository at this point in the history
Fixes #136715
  • Loading branch information
alexr00 committed Nov 9, 2021
1 parent ee9d044 commit 056fa40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/vs/workbench/contrib/tasks/browser/runAutomaticTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,22 @@ export class RunAutomaticTasks extends Disposable implements IWorkbenchContribut
}

private async tryRunTasks() {
this.logService.info('RunAutomaticTasks: Trying to run tasks.');
this.logService.trace('RunAutomaticTasks: Trying to run tasks.');
// Wait until we have task system info (the extension host and workspace folders are available).
if (!this.taskService.hasTaskSystemInfo) {
this.logService.info('RunAutomaticTasks: Awaiting task system info.');
this.logService.trace('RunAutomaticTasks: Awaiting task system info.');
await Event.toPromise(Event.once(this.taskService.onDidChangeTaskSystemInfo));
}

this.logService.info('RunAutomaticTasks: Checking if automatic tasks should run.');
this.logService.trace('RunAutomaticTasks: Checking if automatic tasks should run.');
const isFolderAutomaticAllowed = this.storageService.getBoolean(ARE_AUTOMATIC_TASKS_ALLOWED_IN_WORKSPACE, StorageScope.WORKSPACE, undefined);
await this.workspaceTrustManagementService.workspaceTrustInitialized;
const isWorkspaceTrusted = this.workspaceTrustManagementService.isWorkspaceTrusted();
// Only run if allowed. Prompting for permission occurs when a user first tries to run a task.
if (isFolderAutomaticAllowed && isWorkspaceTrusted) {
this.taskService.getWorkspaceTasks(TaskRunSource.FolderOpen).then(workspaceTaskResult => {
let { tasks } = RunAutomaticTasks.findAutoTasks(this.taskService, workspaceTaskResult);
this.logService.info(`RunAutomaticTasks: Found ${tasks.length} automatic tasks tasks`);
this.logService.trace(`RunAutomaticTasks: Found ${tasks.length} automatic tasks tasks`);

if (tasks.length > 0) {
RunAutomaticTasks.runTasks(this.taskService, tasks);
Expand Down

0 comments on commit 056fa40

Please sign in to comment.