vscode-postrefactor: enforcing more reentrancy

This commit is contained in:
Veetaha 2020-03-14 02:01:28 +02:00
parent 7f02d4657b
commit d7b46e0527
2 changed files with 7 additions and 4 deletions

View file

@ -97,7 +97,7 @@ async function askToDownloadProperExtensionVersion(config: Config, reason = "")
* *
* ACHTUNG!: this function has a crazy amount of state transitions, handling errors during * ACHTUNG!: this function has a crazy amount of state transitions, handling errors during
* each of them would result in a ton of code (especially accounting for cross-process * each of them would result in a ton of code (especially accounting for cross-process
* shared mutable `globalState` access). Enforcing reentrancy for this is best-effort. * shared mutable `globalState` access). Enforcing no reentrancy for this is best-effort.
*/ */
const tryDownloadNightlyExtension = notReentrant(async function tryDownloadNightlyExtension( const tryDownloadNightlyExtension = notReentrant(async function tryDownloadNightlyExtension(
config: Config, config: Config,

View file

@ -5,7 +5,7 @@ import { spawnSync } from "child_process";
import { ArtifactSource } from "./interfaces"; import { ArtifactSource } from "./interfaces";
import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info"; import { fetchArtifactReleaseInfo } from "./fetch_artifact_release_info";
import { downloadArtifactWithProgressUi } from "./downloads"; import { downloadArtifactWithProgressUi } from "./downloads";
import { log, assert } from "../util"; import { log, assert, notReentrant } from "../util";
import { Config, NIGHTLY_TAG } from "../config"; import { Config, NIGHTLY_TAG } from "../config";
export async function ensureServerBinary(config: Config): Promise<null | string> { export async function ensureServerBinary(config: Config): Promise<null | string> {
@ -82,7 +82,10 @@ function shouldDownloadServer(
return installed.date.getTime() !== required.date.getTime(); return installed.date.getTime() !== required.date.getTime();
} }
async function downloadServer( /**
* Enforcing no reentrancy for this is best-effort.
*/
const downloadServer = notReentrant(async function downloadServer(
source: ArtifactSource.GithubRelease, source: ArtifactSource.GithubRelease,
config: Config, config: Config,
): Promise<null | string> { ): Promise<null | string> {
@ -112,7 +115,7 @@ async function downloadServer(
); );
return binaryPath; return binaryPath;
} });
function isBinaryAvailable(binaryPath: string): boolean { function isBinaryAvailable(binaryPath: string): boolean {
const res = spawnSync(binaryPath, ["--version"]); const res = spawnSync(binaryPath, ["--version"]);