Make file hash checker
This commit is contained in:
parent
a1aa7e67e4
commit
60d6e4c0eb
10
src/main.js
10
src/main.js
@ -29,6 +29,14 @@ let plutoniumManifest = {
|
|||||||
"baseUrl": "https://cdn.plutonium.pw/updater/prod/files/",
|
"baseUrl": "https://cdn.plutonium.pw/updater/prod/files/",
|
||||||
"files": []
|
"files": []
|
||||||
};
|
};
|
||||||
|
let userInfo = {
|
||||||
|
"token": "V3ryS3cr3t4uth3nt1c4t10nT0k3n",
|
||||||
|
"userId": -1,
|
||||||
|
"username": "AnonGuest",
|
||||||
|
"email": "guest@neverla.nd",
|
||||||
|
"emailVerified": false,
|
||||||
|
"avatar": "https://forum.plutonium.pw/assets/uploads/system/avatar-default.png"
|
||||||
|
};
|
||||||
|
|
||||||
function createMainWindow() {
|
function createMainWindow() {
|
||||||
mainWindow = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
@ -142,6 +150,8 @@ electron.ipcMain.handle("login", function (event, username, password) {
|
|||||||
...data
|
...data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
userInfo = data;
|
||||||
|
|
||||||
mainWindow.loadFile(path.join(__dirname, "src", "views", "games.html"));
|
mainWindow.loadFile(path.join(__dirname, "src", "views", "games.html"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
39
src/update.js
Normal file
39
src/update.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
const path = require("node:path");
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const crypto = require("node:crypto");
|
||||||
|
|
||||||
|
function checkFileAgainstSHA1(baseDirectory, fileEntry) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
let filePath = path.join(baseDirectory, fileEntry.name);
|
||||||
|
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
return resolve({
|
||||||
|
"entry": fileEntry,
|
||||||
|
"ok": false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let hash = crypto.createHash("sha1");
|
||||||
|
hash.setEncoding("hex");
|
||||||
|
|
||||||
|
let fileInputStream = fs.createReadStream(filePath);
|
||||||
|
|
||||||
|
hash.on("readable", function () {
|
||||||
|
let data = hash.read();
|
||||||
|
if (data) {
|
||||||
|
resolve({
|
||||||
|
"entry": fileEntry,
|
||||||
|
"ok": data == fileEntry.hash
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fileInputStream.pipe(hash);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
"checkFiles": function (manifest) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user