mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2025-01-03 09:29:36 +00:00
Zip extraction implementation
Some checks are pending
MacOS Build / build (20) (push) Waiting to run
Ubuntu 22.04 - AppImage Build / build (20) (push) Waiting to run
Ubuntu 22.04 - x64 DEB Build / build (20) (push) Waiting to run
Ubuntu 24.04 - x64 DEB Build / build (20) (push) Waiting to run
Windows Build / build (20) (push) Waiting to run
Some checks are pending
MacOS Build / build (20) (push) Waiting to run
Ubuntu 22.04 - AppImage Build / build (20) (push) Waiting to run
Ubuntu 22.04 - x64 DEB Build / build (20) (push) Waiting to run
Ubuntu 24.04 - x64 DEB Build / build (20) (push) Waiting to run
Windows Build / build (20) (push) Waiting to run
This commit is contained in:
parent
32530c65f9
commit
2614ad0919
3 changed files with 81 additions and 3 deletions
44
app/main.ts
44
app/main.ts
|
@ -10,6 +10,7 @@ import * as tar from 'tar';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as pidusage from 'pidusage';
|
import * as pidusage from 'pidusage';
|
||||||
import AutoLaunch from './auto-launch';
|
import AutoLaunch from './auto-launch';
|
||||||
|
import AdmZip from 'adm-zip';
|
||||||
|
|
||||||
interface Stats {
|
interface Stats {
|
||||||
/**
|
/**
|
||||||
|
@ -529,6 +530,47 @@ const extractTarBz2 = (filePath: string, destination: string): Promise<string> =
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const extractZip = (filePath: string, destination: string): Promise<string> => {
|
||||||
|
return new Promise<string>((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const zip = new AdmZip(filePath);
|
||||||
|
|
||||||
|
// Ensure destination exists
|
||||||
|
if (!fs.existsSync(destination)) {
|
||||||
|
fs.mkdirSync(destination, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the ZIP file
|
||||||
|
zip.extractAllTo(destination, true);
|
||||||
|
|
||||||
|
// Get the name of the extracted folder
|
||||||
|
const extractedEntries = zip.getEntries();
|
||||||
|
const folderName = extractedEntries[0]?.entryName.split('/')[0];
|
||||||
|
|
||||||
|
// Ensure folder name exists
|
||||||
|
if (!folderName) {
|
||||||
|
reject(new Error("Could not determine the extracted folder name"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve(path.join(destination, folderName));
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const extract = (filePath: string, destination: string): Promise<string> => {
|
||||||
|
if (filePath.endsWith('.zip')) {
|
||||||
|
return extractZip(filePath, destination);
|
||||||
|
}
|
||||||
|
else if (filePath.endsWith('.tar.bz2')) {
|
||||||
|
return extractTarBz2(filePath, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("Unknown file type " + filePath);
|
||||||
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
function showNotification(options?: NotificationConstructorOptions): void {
|
function showNotification(options?: NotificationConstructorOptions): void {
|
||||||
|
@ -637,7 +679,7 @@ try {
|
||||||
// Estrai il file
|
// Estrai il file
|
||||||
const fPath = `${destination}/${fileName}`;
|
const fPath = `${destination}/${fileName}`;
|
||||||
event.sender.send('download-progress', { progress: 100, status: 'Extracting' });
|
event.sender.send('download-progress', { progress: 100, status: 'Extracting' });
|
||||||
const extractedDir = await extractTarBz2(fPath, destination);
|
const extractedDir = await extract(fPath, destination);
|
||||||
|
|
||||||
event.sender.send('download-progress', { progress: 100, status: 'Download and extraction completed successfully' });
|
event.sender.send('download-progress', { progress: 100, status: 'Download and extraction completed successfully' });
|
||||||
event.sender.send('download-progress', { progress: 200, status: `${destination}/${extractedDir}` });
|
event.sender.send('download-progress', { progress: 200, status: `${destination}/${extractedDir}` });
|
||||||
|
|
38
app/package-lock.json
generated
38
app/package-lock.json
generated
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "monerod-gui",
|
"name": "monerod-gui",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "monerod-gui",
|
"name": "monerod-gui",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"adm-zip": "^0.5.16",
|
||||||
"applescript": "^1.0.0",
|
"applescript": "^1.0.0",
|
||||||
"os": "^0.1.2",
|
"os": "^0.1.2",
|
||||||
"pidusage": "^3.0.2",
|
"pidusage": "^3.0.2",
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
"winreg": "^1.2.5"
|
"winreg": "^1.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/adm-zip": "^0.5.5",
|
||||||
"@types/auto-launch": "^5.0.5",
|
"@types/auto-launch": "^5.0.5",
|
||||||
"@types/pidusage": "^2.0.5",
|
"@types/pidusage": "^2.0.5",
|
||||||
"@types/winreg": "^1.2.36"
|
"@types/winreg": "^1.2.36"
|
||||||
|
@ -57,12 +59,30 @@
|
||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/adm-zip": {
|
||||||
|
"version": "0.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.5.tgz",
|
||||||
|
"integrity": "sha512-YCGstVMjc4LTY5uK9/obvxBya93axZOVOyf2GSUulADzmLhYE45u2nAssCs/fWBs1Ifq5Vat75JTPwd5XZoPJw==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/auto-launch": {
|
"node_modules/@types/auto-launch": {
|
||||||
"version": "5.0.5",
|
"version": "5.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/auto-launch/-/auto-launch-5.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/auto-launch/-/auto-launch-5.0.5.tgz",
|
||||||
"integrity": "sha512-/nGvQZSzM/pvCMCh4Gt2kIeiUmOP/cKGJbjlInI+A+5MoV/7XmT56DJ6EU8bqc3+ItxEe4UC2GVspmPzcCc8cg==",
|
"integrity": "sha512-/nGvQZSzM/pvCMCh4Gt2kIeiUmOP/cKGJbjlInI+A+5MoV/7XmT56DJ6EU8bqc3+ItxEe4UC2GVspmPzcCc8cg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "22.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.0.tgz",
|
||||||
|
"integrity": "sha512-84rafSBHC/z1i1E3p0cJwKA+CfYDNSXX9WSZBRopjIzLET8oNt6ht2tei4C7izwDeEiLLfdeSVBv1egOH916hg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~6.19.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/pidusage": {
|
"node_modules/@types/pidusage": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/pidusage/-/pidusage-2.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/pidusage/-/pidusage-2.0.5.tgz",
|
||||||
|
@ -75,6 +95,14 @@
|
||||||
"integrity": "sha512-DtafHy5A8hbaosXrbr7YdjQZaqVewXmiasRS5J4tYMzt3s1gkh40ixpxgVFfKiQ0JIYetTJABat47v9cpr/sQg==",
|
"integrity": "sha512-DtafHy5A8hbaosXrbr7YdjQZaqVewXmiasRS5J4tYMzt3s1gkh40ixpxgVFfKiQ0JIYetTJABat47v9cpr/sQg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/adm-zip": {
|
||||||
|
"version": "0.5.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.16.tgz",
|
||||||
|
"integrity": "sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/ansi-regex": {
|
"node_modules/ansi-regex": {
|
||||||
"version": "6.1.0",
|
"version": "6.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz",
|
||||||
|
@ -562,6 +590,12 @@
|
||||||
"through": "^2.3.8"
|
"through": "^2.3.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "6.19.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
|
||||||
|
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/which": {
|
"node_modules/which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"adm-zip": "^0.5.16",
|
||||||
"applescript": "^1.0.0",
|
"applescript": "^1.0.0",
|
||||||
"os": "^0.1.2",
|
"os": "^0.1.2",
|
||||||
"pidusage": "^3.0.2",
|
"pidusage": "^3.0.2",
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
"winreg": "^1.2.5"
|
"winreg": "^1.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/adm-zip": "^0.5.5",
|
||||||
"@types/auto-launch": "^5.0.5",
|
"@types/auto-launch": "^5.0.5",
|
||||||
"@types/pidusage": "^2.0.5",
|
"@types/pidusage": "^2.0.5",
|
||||||
"@types/winreg": "^1.2.36"
|
"@types/winreg": "^1.2.36"
|
||||||
|
|
Loading…
Reference in a new issue