From e02a2202756ea0a76171a973f974afa35e9ea205 Mon Sep 17 00:00:00 2001 From: xssdoctor Date: Sun, 28 Apr 2024 14:10:24 -0400 Subject: [PATCH] fixed update patterns in gui --- installer/client/gui/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/installer/client/gui/main.js b/installer/client/gui/main.js index 0d14c33..62f6e1e 100644 --- a/installer/client/gui/main.js +++ b/installer/client/gui/main.js @@ -1,5 +1,6 @@ const { app, BrowserWindow, ipcMain, dialog } = require("electron"); const fs = require("fs").promises; +const fsp = require("fs"); const path = require("path"); const os = require("os"); const OpenAI = require("openai"); @@ -48,7 +49,7 @@ async function downloadAndUpdatePatterns() { }); const zipPath = path.join(os.tmpdir(), "fabric.zip"); - fs.writeFileSync(zipPath, response.data); + await fs.writeFile(zipPath, response.data); console.log("Zip file written to:", zipPath); // Prepare for extraction @@ -56,7 +57,7 @@ async function downloadAndUpdatePatterns() { await fsExtra.emptyDir(tempExtractPath); // Extract the zip file - await fs + await fsp .createReadStream(zipPath) .pipe(unzipper.Extract({ path: tempExtractPath })) .promise(); @@ -75,10 +76,10 @@ async function downloadAndUpdatePatterns() { "fabric", "patterns" ); - if (fs.existsSync(existingPatternsPath)) { + if (fsp.existsSync(existingPatternsPath)) { const existingFolders = await fsExtra.readdir(existingPatternsPath); for (const folder of existingFolders) { - if (!fs.existsSync(path.join(extractedPatternsPath, folder))) { + if (!fsp.existsSync(path.join(extractedPatternsPath, folder))) { await fsExtra.move( path.join(existingPatternsPath, folder), path.join(extractedPatternsPath, folder)