mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-10-20 08:38:32 +00:00
fix: try fetch the sketch by path if not in the cache
The sketch cache might be empty, when trying to generate the secrets include in the main sketch file from the `secrets` property. Closes #1999 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { FileStat } from '@theia/filesystem/lib/common/files';
|
||||
import { injectable } from '@theia/core/shared/inversify';
|
||||
import { toPosixPath } from '../../create/create-paths';
|
||||
import { splitSketchPath } from '../../create/create-paths';
|
||||
import { Create } from '../../create/typings';
|
||||
|
||||
@injectable()
|
||||
export class SketchCache {
|
||||
sketches: Record<string, Create.Sketch> = {};
|
||||
fileStats: Record<string, FileStat> = {};
|
||||
private _createPathPrefix: string | undefined;
|
||||
|
||||
init(): void {
|
||||
// reset the data
|
||||
@@ -32,7 +33,10 @@ export class SketchCache {
|
||||
|
||||
addSketch(sketch: Create.Sketch): void {
|
||||
const { path } = sketch;
|
||||
const posixPath = toPosixPath(path);
|
||||
const [pathPrefix, posixPath] = splitSketchPath(path);
|
||||
if (pathPrefix !== this._createPathPrefix) {
|
||||
this._createPathPrefix = pathPrefix;
|
||||
}
|
||||
this.sketches[posixPath] = sketch;
|
||||
}
|
||||
|
||||
@@ -40,6 +44,10 @@ export class SketchCache {
|
||||
return this.sketches[path] || null;
|
||||
}
|
||||
|
||||
get createPathPrefix(): string | undefined {
|
||||
return this._createPathPrefix;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return JSON.stringify({
|
||||
sketches: this.sketches,
|
||||
|
||||
Reference in New Issue
Block a user