Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path failure preventing trace from opening #184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions vscode-trace-extension/src/trace-explorer/trace-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ export const fileHandler =
return;
}

const uri: string = resolvedTraceURI.path;
if (!uri) {
const filePath: string = resolvedTraceURI.fsPath;
if (!filePath) {
traceLogger.addLogMessage(
'Cannot open trace: could not retrieve path from URI for trace ' + resolvedTraceURI,
fileHandler.name
);
return;
}

const name = uri.substring(uri.lastIndexOf('/') + 1);
const name = path.basename(filePath);
const panel = TraceViewerPanel.createOrShow(context.extensionUri, name, undefined);

progress.report({ message: ProgressMessages.FINDING_TRACES, increment: 10 });
Expand All @@ -187,11 +187,11 @@ export const fileHandler =
if (fileStat) {
if (fileStat.type === vscode.FileType.Directory) {
// Find recursively CTF traces
const foundTraces = await findTraces(uri);
const foundTraces = await findTraces(filePath);
foundTraces.forEach(trace => tracesArray.push(trace));
} else {
// Open single trace file
tracesArray.push(uri);
tracesArray.push(filePath);
}
}

Expand All @@ -208,7 +208,7 @@ export const fileHandler =
progress.report({ message: ProgressMessages.OPENING_TRACES, increment: 20 });
const traces = new Array<TspTrace>();
for (let i = 0; i < tracesArray.length; i++) {
const traceName = tracesArray[i].substring(tracesArray[i].lastIndexOf('/') + 1);
const traceName = path.basename(tracesArray[i]);
const trace = await traceManager.openTrace(tracesArray[i], traceName);
if (trace) {
traces.push(trace);
Expand Down Expand Up @@ -291,7 +291,7 @@ const findTraces = async (directory: string): Promise<string[]> => {
const childrenArr = await vscode.workspace.fs.readDirectory(uri);
for (const child of childrenArr) {
if (child[1] === vscode.FileType.Directory) {
const subTraces = await findTraces(directory + '/' + child[0]);
const subTraces = await findTraces(path.join(directory, child[0]));
subTraces.forEach(trace => traces.push(trace));
}
}
Expand All @@ -311,8 +311,8 @@ const isCtf = async (directory: string): Promise<boolean> => {
};

function getProgressBarTitle(traceUri: vscode.Uri | undefined): string {
if (!traceUri || !traceUri.path) {
if (!traceUri || !traceUri.fsPath) {
return 'undefined';
}
return traceUri.path.substring(traceUri.path.lastIndexOf('/') + 1);
return path.basename(traceUri.fsPath);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from 'vscode';
import * as path from 'path';
import { Experiment } from 'tsp-typescript-client/lib/models/experiment';
import { getTspClientUrl, getTraceServerUrl } from '../utils/tspClient';
import { TraceServerConnectionStatusService } from '../utils/trace-server-status';
Expand Down Expand Up @@ -115,7 +116,7 @@ export class TraceViewerPanel {
private static async saveTraceCsv(csvData: string, defaultFileName: string) {
const saveDialogOptions = {
defaultUri: vscode.workspace.workspaceFolders
? vscode.Uri.file(vscode.workspace.workspaceFolders[0].uri.path + '/' + defaultFileName)
? vscode.Uri.file(path.join(vscode.workspace.workspaceFolders[0].uri.fsPath, defaultFileName))
: undefined,
saveLabel: 'Save as CSV',
filters: {
Expand Down