mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-08 07:11:06 +00:00
fixed update patterns in gui
This commit is contained in:
parent
efa8df2dcd
commit
e02a220275
@ -1,5 +1,6 @@
|
|||||||
const { app, BrowserWindow, ipcMain, dialog } = require("electron");
|
const { app, BrowserWindow, ipcMain, dialog } = require("electron");
|
||||||
const fs = require("fs").promises;
|
const fs = require("fs").promises;
|
||||||
|
const fsp = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
const OpenAI = require("openai");
|
const OpenAI = require("openai");
|
||||||
@ -48,7 +49,7 @@ async function downloadAndUpdatePatterns() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const zipPath = path.join(os.tmpdir(), "fabric.zip");
|
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);
|
console.log("Zip file written to:", zipPath);
|
||||||
|
|
||||||
// Prepare for extraction
|
// Prepare for extraction
|
||||||
@ -56,7 +57,7 @@ async function downloadAndUpdatePatterns() {
|
|||||||
await fsExtra.emptyDir(tempExtractPath);
|
await fsExtra.emptyDir(tempExtractPath);
|
||||||
|
|
||||||
// Extract the zip file
|
// Extract the zip file
|
||||||
await fs
|
await fsp
|
||||||
.createReadStream(zipPath)
|
.createReadStream(zipPath)
|
||||||
.pipe(unzipper.Extract({ path: tempExtractPath }))
|
.pipe(unzipper.Extract({ path: tempExtractPath }))
|
||||||
.promise();
|
.promise();
|
||||||
@ -75,10 +76,10 @@ async function downloadAndUpdatePatterns() {
|
|||||||
"fabric",
|
"fabric",
|
||||||
"patterns"
|
"patterns"
|
||||||
);
|
);
|
||||||
if (fs.existsSync(existingPatternsPath)) {
|
if (fsp.existsSync(existingPatternsPath)) {
|
||||||
const existingFolders = await fsExtra.readdir(existingPatternsPath);
|
const existingFolders = await fsExtra.readdir(existingPatternsPath);
|
||||||
for (const folder of existingFolders) {
|
for (const folder of existingFolders) {
|
||||||
if (!fs.existsSync(path.join(extractedPatternsPath, folder))) {
|
if (!fsp.existsSync(path.join(extractedPatternsPath, folder))) {
|
||||||
await fsExtra.move(
|
await fsExtra.move(
|
||||||
path.join(existingPatternsPath, folder),
|
path.join(existingPatternsPath, folder),
|
||||||
path.join(extractedPatternsPath, folder)
|
path.join(extractedPatternsPath, folder)
|
||||||
|
Loading…
Reference in New Issue
Block a user