Use containsPath where possible
This commit is contained in:
@@ -14,6 +14,7 @@ import { DatabaseItem } from "../databases/local-databases";
|
|||||||
import { getQlPackPath, QLPACK_FILENAMES } from "../pure/ql";
|
import { getQlPackPath, QLPACK_FILENAMES } from "../pure/ql";
|
||||||
import { getErrorMessage } from "../pure/helpers-pure";
|
import { getErrorMessage } from "../pure/helpers-pure";
|
||||||
import { ExtensionPack, ExtensionPackModelFile } from "./shared/extension-pack";
|
import { ExtensionPack, ExtensionPackModelFile } from "./shared/extension-pack";
|
||||||
|
import { containsPath } from "../pure/files";
|
||||||
|
|
||||||
const maxStep = 3;
|
const maxStep = 3;
|
||||||
|
|
||||||
@@ -347,11 +348,7 @@ async function pickNewModelFile(
|
|||||||
return "File already exists";
|
return "File already exists";
|
||||||
}
|
}
|
||||||
|
|
||||||
const notInExtensionPack = relative(
|
if (!containsPath(extensionPack.path, path)) {
|
||||||
extensionPack.path,
|
|
||||||
path,
|
|
||||||
).startsWith("..");
|
|
||||||
if (notInExtensionPack) {
|
|
||||||
return "File must be in the extension pack";
|
return "File must be in the extension pack";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import * as cli from "../../codeql-cli/cli";
|
import * as cli from "../../codeql-cli/cli";
|
||||||
import vscode from "vscode";
|
import vscode from "vscode";
|
||||||
import { FullDatabaseOptions } from "./database-options";
|
import { FullDatabaseOptions } from "./database-options";
|
||||||
import { basename, dirname, extname, join, relative } from "path";
|
import { basename, dirname, extname, join } from "path";
|
||||||
import {
|
import {
|
||||||
decodeSourceArchiveUri,
|
decodeSourceArchiveUri,
|
||||||
encodeArchiveBasePath,
|
encodeArchiveBasePath,
|
||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
import { DatabaseItem, PersistedDatabaseItem } from "./database-item";
|
import { DatabaseItem, PersistedDatabaseItem } from "./database-item";
|
||||||
import { isLikelyDatabaseRoot } from "./db-contents-heuristics";
|
import { isLikelyDatabaseRoot } from "./db-contents-heuristics";
|
||||||
import { stat } from "fs-extra";
|
import { stat } from "fs-extra";
|
||||||
import { pathsEqual } from "../../pure/files";
|
import { containsPath, pathsEqual } from "../../pure/files";
|
||||||
import { DatabaseContents } from "./database-contents";
|
import { DatabaseContents } from "./database-contents";
|
||||||
|
|
||||||
export class DatabaseItemImpl implements DatabaseItem {
|
export class DatabaseItemImpl implements DatabaseItem {
|
||||||
@@ -199,7 +199,7 @@ export class DatabaseItemImpl implements DatabaseItem {
|
|||||||
try {
|
try {
|
||||||
const stats = await stat(testPath);
|
const stats = await stat(testPath);
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
return !relative(testPath, databasePath).startsWith("..");
|
return containsPath(testPath, databasePath);
|
||||||
} else {
|
} else {
|
||||||
// database for /one/two/three/test.ql is at /one/two/three/three.testproj
|
// database for /one/two/three/test.ql is at /one/two/three/three.testproj
|
||||||
const testdir = dirname(testPath);
|
const testdir = dirname(testPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user