fix hwid error handling #21

Merged
HorizonCode merged 1 commits from dev into master 2024-07-21 19:48:52 +00:00
Showing only changes of commit d171545f18 - Show all commits

View File

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