Skip to content

Commit fc8d1fd

Browse files
committed
1.2.0
Redownload Sparkle if its installed already!
1 parent 2eadcbc commit fc8d1fd

File tree

4 files changed

+84
-27
lines changed

4 files changed

+84
-27
lines changed

main.js

+61-23
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,71 @@ function createWindow() {
2121
contextIsolation: false,
2222
},
2323
});
24-
electronDL();
2524

26-
// Rest of your code...
27-
28-
function downloadBatchFile() {
29-
const downloadURL =
30-
"https://raw.githubusercontent.com/Parcoil/Sparkle/main/update.bat";
25+
function downloadAndExtractSparkle() {
26+
const downloadURL = `https://github.com/Parcoil/Sparkle/releases/latest/download/win-unpacked.zip`;
3127
const downloadDir = app.getPath("userData");
32-
const downloadPath = path.join(downloadDir, "update.bat");
33-
34-
electronDL
35-
.download(BrowserWindow.getFocusedWindow(), downloadURL, {
36-
directory: downloadDir,
37-
filename: "update.bat", // Set the desired filename
38-
overwrite: true, // Overwrite the file if it already exists
39-
})
40-
.then((dl) => {
41-
console.log(`Downloaded to ${dl.getSavePath()}`);
42-
43-
// Run the downloaded batch file as administrator
44-
runBatFile(dl.getSavePath());
45-
})
46-
.catch((error) => {
47-
console.error(`Error downloading the file: ${error}`);
28+
const downloadPath = path.join(downloadDir, "win-unpacked.zip");
29+
const extractionPath = `C:\\Users\\${process.env.USERNAME}\\AppData\\Local\\Programs\\sparkle`;
30+
31+
// Kill the Sparkle.exe process twice before downloading
32+
killSparkleProcess(() => {
33+
killSparkleProcess(() => {
34+
electronDL
35+
.download(BrowserWindow.getFocusedWindow(), downloadURL, {
36+
directory: downloadDir,
37+
filename: "win-unpacked.zip",
38+
overwrite: true,
39+
})
40+
.then((dl) => {
41+
console.log(`Downloaded to ${dl.getSavePath()}`);
42+
43+
// Extract the downloaded zip file to the specified path
44+
extractZip(dl.getSavePath(), extractionPath);
45+
46+
// You can add further actions here after extraction if needed
47+
})
48+
.catch((error) => {
49+
console.error(`Error downloading the file: ${error}`);
50+
});
4851
});
52+
});
53+
}
54+
55+
function extractZip(zipFilePath, extractionPath) {
56+
exec(
57+
`powershell Expand-Archive -Path "${zipFilePath}" -DestinationPath "${extractionPath}" -Force`,
58+
(error, stdout, stderr) => {
59+
if (error) {
60+
console.error(`Error extracting zip: ${error.message}`);
61+
return;
62+
}
63+
if (stderr) {
64+
console.error(`Zip extraction stderr: ${stderr}`);
65+
return;
66+
}
67+
console.log(`Zip extracted to ${extractionPath}`);
68+
}
69+
);
4970
}
5071

72+
function killSparkleProcess(callback) {
73+
// Kill Sparkle.exe process
74+
exec("taskkill /f /im Sparkle.exe", (error, stdout, stderr) => {
75+
if (error) {
76+
console.error(`Error killing Sparkle.exe process: ${error.message}`);
77+
}
78+
if (stderr) {
79+
console.error(`Sparkle.exe process termination stderr: ${stderr}`);
80+
}
81+
console.log("Sparkle.exe process terminated.");
82+
callback();
83+
});
84+
}
85+
86+
// Call the function to initiate the download and extraction process
87+
downloadAndExtractSparkle();
88+
5189
// Trigger the batch file download when the app is ready
5290

5391
client.on("ready", () => {
@@ -93,7 +131,7 @@ function createWindow() {
93131
});
94132

95133
ipcMain.on("run-update-batch", () => {
96-
downloadBatchFile();
134+
downloadAndExtractSparkle();
97135
});
98136

99137
const batFilePath =

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sparkle",
33
"main": "main.js",
4-
"version": "1.0.8",
4+
"version": "1.2.0",
55
"author": "The Parcoil network",
66
"scripts": {
77
"start": "electron .",

settings.html

+18-3
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,39 @@
3333
<a href="index.html"><button class="nostyle">Home</button></a>
3434
<a><button class="nostyle" id="runDebloat">Debloat</button></a>
3535
<a><button class="nostyle" id="runClean">Cleaner</button></a>
36-
37-
<a><button class="nostyle" id="internet">Drivers</button></a>
38-
<a><button class="nostyle" id="internet">Wifi Booster</button></a>
36+
<a><button class="nostyle" id="internet">Wifi Booster</button></a>
37+
<a href="settings.html"><button class="nostyle">Settings</button></a>
3938
</div>
4039

4140
<div class="center-content">
4241
<h1><span class="white-text">Settings</span></h1>
4342
<div class="form-check form-switch">
4443
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckDefault" checked>
4544
<label class="form-check-label" for="flexSwitchCheckDefault">Discord RPC </label>
45+
4646
</div>
47+
48+
49+
4750
<button class="btn btn-primary mt-4" id="checkUpdatesBtn">Check for updates</button>
4851

4952
<div class="text-center mt-5">
53+
<p id="updateProgress">Update progress located on taskbar</p>
5054
<p class="mt-5" style="color:#4c4c4c">&copy; 2024 Parcoil Network </p>
5155
</div>
5256
<script src="script.js"></script>
5357
</body>
58+
<script>
59+
document.getElementById("checkUpdatesBtn").addEventListener("click", function () {
60+
// Show the text
61+
document.getElementById("updateProgress").style.display = "block";
62+
63+
// Hide the text after 5 seconds
64+
setTimeout(function () {
65+
document.getElementById("updateProgress").style.display = "none";
66+
}, 5000); // 5000 milliseconds = 5 seconds
67+
});
68+
</script>
5469
<script>
5570

5671

styles.css

+4
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,7 @@ body::-webkit-scrollbar {
117117
.gone {
118118
display: none;
119119
}
120+
121+
#updateProgress {
122+
display: none;
123+
}

0 commit comments

Comments
 (0)