diff --git a/package-lock.json b/package-lock.json index f62811e..6aa78e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "security-notes", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "security-notes", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "@types/uuid": "^9.0.0", diff --git a/package.json b/package.json index 4d8b507..ab99057 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Security Notes", "description": "Create notes during a security code review. Import your favorite SAST tool results and collaborate with others.", "icon": "resources/security_notes_logo.png", - "version": "1.0.0", + "version": "1.0.1", "publisher": "refactor-security", "private": false, "license": "MIT", diff --git a/src/persistence/local-db/index.ts b/src/persistence/local-db/index.ts index 5b7297e..e7948ab 100644 --- a/src/persistence/local-db/index.ts +++ b/src/persistence/local-db/index.ts @@ -5,8 +5,9 @@ import { Serializer } from '../serialization/serializer'; import { Deserializer } from '../serialization/deserializer'; import { CommentThread } from 'vscode'; import { getSetting } from '../../helpers'; +import { getLocalDbFilePath } from '../../utils'; -const persistenceFile = getSetting('localDatabase'); +const persistenceFile = getLocalDbFilePath(); export const saveCommentsToFile = (noteList: Map) => { fs.writeFileSync(persistenceFile, JSON.stringify(Serializer.serialize(noteList))); diff --git a/src/persistence/serialization/serializer.ts b/src/persistence/serialization/serializer.ts index 2922cb8..65d201d 100644 --- a/src/persistence/serialization/serializer.ts +++ b/src/persistence/serialization/serializer.ts @@ -49,7 +49,7 @@ export class Serializer { thread.comments.forEach((comment) => { serializedComments.push(this.serializeComment(comment)); }); - let uri = fullPathToRelative(thread.uri.path); + let uri = fullPathToRelative(thread.uri.fsPath); if (isWindows()) { uri = pathToPosix(uri); } diff --git a/src/utils/index.ts b/src/utils/index.ts index 2237639..5dbfae3 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -3,6 +3,7 @@ import * as vscode from 'vscode'; import * as path from 'path'; import { platform } from 'os'; +import { getSetting } from '../helpers'; export const isWindows = () => { return platform() === 'win32'; @@ -18,12 +19,21 @@ export const pathToWin32 = (aPath: string) => { export const getWorkspacePath = () => { if (vscode.workspace.workspaceFolders) { - return vscode.workspace.workspaceFolders[0].uri.path; + return vscode.workspace.workspaceFolders[0].uri.fsPath; } else { return ''; } }; +export const getLocalDbFilePath = () => { + const localDbFilePath = getSetting('localDatabase'); + if (path.isAbsolute(localDbFilePath)) { + return localDbFilePath; + } else { + return relativePathToFull(localDbFilePath); + } +}; + export const relativePathToFull = (aPath: string, basePath?: string) => { if (basePath) { return path.join(basePath, aPath);