Skip to content

Commit

Permalink
Merge pull request #313 from KxSystems/KXI-46528
Browse files Browse the repository at this point in the history
KXI-46528: Regression: Import old style data sources into .kx folder
  • Loading branch information
ecmel authored May 22, 2024
2 parents 0807621 + 9e4451f commit a10d52f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ext } from "../extensionVariables";
import { DataSourceFiles } from "../models/dataSource";
import { DataSourcesPanel } from "../panels/datasource";
import { InsightsConnection } from "../classes/insightsConnection";
import { workspace, window } from "vscode";
import { workspace, window, Uri } from "vscode";
import { Telemetry } from "./telemetryClient";

export function createKdbDataSourcesFolder(): string {
Expand Down Expand Up @@ -133,13 +133,15 @@ export async function addDSToLocalFolder(ds: DataSourceFiles): Promise<void> {
const folders = workspace.workspaceFolders;
if (folders) {
const folder = folders[0];
const importToUri = Uri.joinPath(folder.uri, ".kx");
await workspace.fs.createDirectory(importToUri);
let i = 1;
let fileName = `datasource-${i}.kdb.json`;
let filePath = path.join(folder.uri.path, fileName);
let filePath = path.join(importToUri.path, fileName);
while (fs.existsSync(filePath)) {
i++;
fileName = `datasource-${i}.kdb.json`;
filePath = path.join(folder.uri.path, fileName);
filePath = path.join(importToUri.path, fileName);
}
fs.writeFileSync(filePath, JSON.stringify(ds));
window.showInformationMessage(`Datasource created.`);
Expand Down

0 comments on commit a10d52f

Please sign in to comment.