From d92fc25769d97c865a327ba8a097606e18f9a4d0 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Tue, 12 Nov 2019 21:36:15 +0100 Subject: [PATCH] Fixed endless loop in the sketch service. Signed-off-by: Akos Kitta --- .../src/node/sketches-service-impl.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arduino-ide-extension/src/node/sketches-service-impl.ts b/arduino-ide-extension/src/node/sketches-service-impl.ts index 2a5ae859..3852d8d8 100644 --- a/arduino-ide-extension/src/node/sketches-service-impl.ts +++ b/arduino-ide-extension/src/node/sketches-service-impl.ts @@ -52,14 +52,16 @@ export class SketchesServiceImpl implements SketchesService { const uris: string[] = []; const fsPath = FileUri.fsPath(uri); const stats = fs.lstatSync(fsPath); - if (stats.isDirectory && await this.isSketchFolder(uri)) { - const fileNames = fs.readdirSync(fsPath); - for (const fileName of fileNames) { - const filePath = path.join(fsPath, fileName); - if (ALLOWED_FILE_EXTENSIONS.indexOf(path.extname(filePath)) !== -1 - && fs.existsSync(filePath) - && fs.lstatSync(filePath).isFile()) { - uris.push(FileUri.create(filePath).toString()) + if (stats.isDirectory) { + if (await this.isSketchFolder(uri)) { + const fileNames = fs.readdirSync(fsPath); + for (const fileName of fileNames) { + const filePath = path.join(fsPath, fileName); + if (ALLOWED_FILE_EXTENSIONS.indexOf(path.extname(filePath)) !== -1 + && fs.existsSync(filePath) + && fs.lstatSync(filePath).isFile()) { + uris.push(FileUri.create(filePath).toString()) + } } } return uris;