Try waiting a few seconds before renaming

This commit is contained in:
Andrew Eisenberg
2024-03-02 16:44:56 -08:00
parent 3497219c68
commit 0ed9242b81
3 changed files with 14 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ import { DB_URL, dbLoc, testprojLoc } from "../global.helper";
import fetch from "node-fetch";
import { renameSync } from "fs";
import { unzipToDirectoryConcurrently } from "../../../src/common/unzip-concurrently";
import { platform } from "os";
import { wait } from "./utils";
beforeAll(async () => {
// ensure the test database is downloaded
@@ -37,6 +39,11 @@ beforeAll(async () => {
if (!existsSync(testprojLoc)) {
console.log(`Unzipping test database to ${testprojLoc}`);
await unzipToDirectoryConcurrently(dbLoc, dbParentDir);
// On Windows, wait a few seconds to make sure all background processes
// release their lock on the files before renaming the directory.
if (platform() === "win32") {
await wait(3000);
}
renameSync(join(dbParentDir, "db"), testprojLoc);
console.log("Unzip completed.");
}

View File

@@ -7,3 +7,7 @@ import { join } from "path";
export function getDataFolderFilePath(path: string): string {
return join(workspace.workspaceFolders![0].uri.fsPath, path);
}
export async function wait(ms = 1000) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

View File

@@ -101,6 +101,9 @@ describe("local databases", () => {
onStart: () => {
/**/
},
onQueryRunStarting: () => {
/**/
},
}),
mockedObject<CodeQLCliServer>({
resolveDatabase: resolveDatabaseSpy,