mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-12 03:43:01 +02:00
Version fixes
This commit is contained in:
@@ -97,6 +97,10 @@ export class Extension {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!versionInfo.usedVersion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Split semantic version
|
// Split semantic version
|
||||||
const version = versionInfo.usedVersion.split('.');
|
const version = versionInfo.usedVersion.split('.');
|
||||||
const major = parseInt(version[0]);
|
const major = parseInt(version[0]);
|
||||||
|
|||||||
@@ -14,11 +14,15 @@ interface MediaRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class MediaLibrary {
|
export class MediaLibrary {
|
||||||
private db: JsonDB;
|
private db: JsonDB | undefined;
|
||||||
private static instance: MediaLibrary;
|
private static instance: MediaLibrary;
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
const wsFolder = Folders.getWorkspaceFolder();
|
const wsFolder = Folders.getWorkspaceFolder();
|
||||||
|
if (!wsFolder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.db = new JsonDB(join(parseWinPath(wsFolder?.fsPath || ""), LocalStore.rootFolder, LocalStore.contentFolder, LocalStore.mediaDatabaseFile), true, false, '/');
|
this.db = new JsonDB(join(parseWinPath(wsFolder?.fsPath || ""), LocalStore.rootFolder, LocalStore.contentFolder, LocalStore.mediaDatabaseFile), true, false, '/');
|
||||||
|
|
||||||
workspace.onDidRenameFiles(e => {
|
workspace.onDidRenameFiles(e => {
|
||||||
@@ -46,7 +50,7 @@ export class MediaLibrary {
|
|||||||
public get(id: string): MediaRecord | undefined {
|
public get(id: string): MediaRecord | undefined {
|
||||||
try {
|
try {
|
||||||
const fileId = this.parsePath(id);
|
const fileId = this.parsePath(id);
|
||||||
if (this.db.exists(fileId)) {
|
if (this.db?.exists(fileId)) {
|
||||||
return this.db.getData(fileId);
|
return this.db.getData(fileId);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -57,16 +61,16 @@ export class MediaLibrary {
|
|||||||
|
|
||||||
public set(id: string, metadata: any): void {
|
public set(id: string, metadata: any): void {
|
||||||
const fileId = this.parsePath(id);
|
const fileId = this.parsePath(id);
|
||||||
this.db.push(fileId, metadata, true);
|
this.db?.push(fileId, metadata, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public rename(oldId: string, newId: string): void {
|
public rename(oldId: string, newId: string): void {
|
||||||
const fileId = this.parsePath(oldId);
|
const fileId = this.parsePath(oldId);
|
||||||
const newFileId = this.parsePath(newId);
|
const newFileId = this.parsePath(newId);
|
||||||
const data = this.db.getData(fileId);
|
const data = this.db?.getData(fileId);
|
||||||
if (data) {
|
if (data) {
|
||||||
this.db.delete(fileId);
|
this.db?.delete(fileId);
|
||||||
this.db.push(newFileId, data, true);
|
this.db?.push(newFileId, data, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user