mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-18 20:33:19 +08:00
fix crash when hosts not exist
This commit is contained in:
4
app.js
4
app.js
@@ -111,12 +111,12 @@ const onExit = () => {
|
|||||||
const merged = Buffer.concat(packets)
|
const merged = Buffer.concat(packets)
|
||||||
const compressed = zlib.brotliCompressSync(merged)
|
const compressed = zlib.brotliCompressSync(merged)
|
||||||
const response = await upload(compressed)
|
const response = await upload(compressed)
|
||||||
|
const data = zlib.brotliDecompressSync(response.data)
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
log(`发生错误: ${response.data.toString()}`)
|
log(`发生错误: ${data}`)
|
||||||
log(`请求ID: ${response.headers["x-api-requestid"]}`)
|
log(`请求ID: ${response.headers["x-api-requestid"]}`)
|
||||||
log("请联系开发者以获取帮助")
|
log("请联系开发者以获取帮助")
|
||||||
} else {
|
} else {
|
||||||
const data = zlib.brotliDecompressSync(response.data)
|
|
||||||
const proto = await decodeProto(data,"AllAchievement")
|
const proto = await decodeProto(data,"AllAchievement")
|
||||||
await exportData(proto)
|
await exportData(proto)
|
||||||
}
|
}
|
||||||
|
|||||||
3
utils.js
3
utils.js
@@ -228,6 +228,9 @@ let hostsContent = ""
|
|||||||
|
|
||||||
const setupHost = (restore = false) => {
|
const setupHost = (restore = false) => {
|
||||||
const path = "C:\\Windows\\System32\\drivers\\etc\\hosts"
|
const path = "C:\\Windows\\System32\\drivers\\etc\\hosts"
|
||||||
|
if (!fs.existsSync(path)) {
|
||||||
|
fs.writeFileSync(path, "")
|
||||||
|
}
|
||||||
fs.chmodSync(path, 0o777)
|
fs.chmodSync(path, 0o777)
|
||||||
if (restore) {
|
if (restore) {
|
||||||
fs.writeFileSync(path, hostsContent)
|
fs.writeFileSync(path, hostsContent)
|
||||||
|
|||||||
Reference in New Issue
Block a user