fix hwid error

This commit is contained in:
HorizonCode 2024-07-21 21:48:44 +02:00
parent 6551f0b369
commit d171545f18

View File

@ -25,12 +25,16 @@ const defaultHWID = "recorderinthesandybridge";
*/ */
function getHwId() { function getHwId() {
return new Promise((resolve) => { return new Promise((resolve) => {
const getter = platforms[process.platform]; try {
if (getter) { const getter = platforms[process.platform];
const result = getter[1].exec(child_process.execSync(getter[0], options)); if (getter) {
if (result) resolve(crypto.createHash("md5").update(result[1]).digest("hex")); const result = getter[1].exec(child_process.execSync(getter[0], options));
if (result) resolve(crypto.createHash("md5").update(result[1]).digest("hex"));
}
resolve(crypto.createHash("md5").update(defaultHWID).digest("hex"));
} catch {
resolve(crypto.createHash("md5").update(defaultHWID).digest("hex"));
} }
resolve(crypto.createHash("md5").update(defaultHWID).digest("hex"));
}) })
} }
exports.getHwId = getHwId; exports.getHwId = getHwId;