Skip to content

Commit

Permalink
Use asycy tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
alexet authored and aeisenberg committed Jan 29, 2021
1 parent 4dfec70 commit 89b8605
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions extensions/ql-vscode/src/run-queries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as crypto from 'crypto';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';
import {
CancellationToken,
ConfigurationTarget,
Expand Down Expand Up @@ -338,7 +338,7 @@ function reportNoUpgradePath(query: QueryInfo) {
*/
async function compileNonDestructiveUpgrade(
qs: qsClient.QueryServerClient,
upgradeTemp: tmp.DirResult,
upgradeTemp: tmp.DirectoryResult,
query: QueryInfo,
progress: ProgressCallback,
token: CancellationToken,
Expand Down Expand Up @@ -552,7 +552,7 @@ export async function compileAndRunQueryAgainstDatabase(

const query = new QueryInfo(qlProgram, db, packConfig.dbscheme, quickEvalPosition, metadata, templates);

const upgradeDir = tmp.dirSync({ dir: upgradesTmpDir.name });
const upgradeDir = await tmp.dir({ dir: upgradesTmpDir.name });
try {
let upgradeQlo;
if (await hasNondestructiveUpgradeCapabilities(qs)) {
Expand Down Expand Up @@ -615,7 +615,7 @@ export async function compileAndRunQueryAgainstDatabase(
return createSyntheticResult(query, db, historyItemOptions, 'Query had compilation errors', messages.QueryResultType.OTHER_ERROR);
}
} finally {
upgradeDir.removeCallback();
upgradeDir.cleanup();
}
}

Expand Down
14 changes: 7 additions & 7 deletions extensions/ql-vscode/src/upgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { logger } from './logging';
import * as messages from './pure/messages';
import * as qsClient from './queryserver-client';
import { upgradesTmpDir } from './run-queries';
import * as tmp from 'tmp';
import * as tmp from 'tmp-promise';
import * as path from 'path';
import * as semver from 'semver';
import { getOnDiskWorkspaceFolders } from './helpers';
Expand Down Expand Up @@ -37,7 +37,7 @@ export async function hasNondestructiveUpgradeCapabilities(qs: qsClient.QuerySer
export async function compileDatabaseUpgradeSequence(qs: qsClient.QueryServerClient,
db: DatabaseItem,
resolvedSequence: string[],
currentUpgradeTmp: tmp.DirResult,
currentUpgradeTmp: tmp.DirectoryResult,
progress: ProgressCallback,
token: vscode.CancellationToken): Promise<messages.CompileUpgradeSequenceResult> {
if (db.contents === undefined || db.contents.dbSchemeUri === undefined) {
Expand All @@ -48,7 +48,7 @@ export async function compileDatabaseUpgradeSequence(qs: qsClient.QueryServerCli
}
// If possible just compile the upgrade sequence
return await qs.sendRequest(messages.compileUpgradeSequence, {
upgradeTempDir: currentUpgradeTmp.name,
upgradeTempDir: currentUpgradeTmp.path,
upgradePaths: resolvedSequence
}, token, progress);
}
Expand All @@ -58,7 +58,7 @@ async function compileDatabaseUpgrade(
db: DatabaseItem,
targetDbScheme: string,
resolvedSequence: string[],
currentUpgradeTmp: tmp.DirResult,
currentUpgradeTmp: tmp.DirectoryResult,
progress: ProgressCallback,
token: vscode.CancellationToken
): Promise<messages.CompileUpgradeResult> {
Expand All @@ -81,7 +81,7 @@ async function compileDatabaseUpgrade(
toDbscheme: targetDbScheme,
additionalUpgrades: Array.from(uniqueParentDirs)
},
upgradeTempDir: currentUpgradeTmp.name,
upgradeTempDir: currentUpgradeTmp.path,
singleFileUpgrades: true,
}, token, progress);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ export async function upgradeDatabaseExplicit(
if (finalDbscheme === undefined) {
throw new Error('Could not determine target dbscheme to upgrade to.');
}
const currentUpgradeTmp = tmp.dirSync({ dir: upgradesTmpDir.name, prefix: 'upgrade_', keep: false, unsafeCleanup: true });
const currentUpgradeTmp = await tmp.dir({ dir: upgradesTmpDir.name, prefix: 'upgrade_', keep: false, unsafeCleanup: true });
try {
let compileUpgradeResult: messages.CompileUpgradeResult;
try {
Expand Down Expand Up @@ -213,7 +213,7 @@ export async function upgradeDatabaseExplicit(
qs.logger.log('Done running database upgrade.');
}
} finally {
currentUpgradeTmp.removeCallback();
currentUpgradeTmp.cleanup();
}
}

Expand Down

0 comments on commit 89b8605

Please sign in to comment.