Skip to content

Commit

Permalink
Fix client auto updater
Browse files Browse the repository at this point in the history
It was using the wrong unzipping library, now we can just use the wget-improved and AdmZip local wrappers
  • Loading branch information
MasterIO02 committed Jul 26, 2023
1 parent ecede83 commit a8985a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
39 changes: 8 additions & 31 deletions files/clientUpdater.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
const path = require("path")
const wget = require("wget-improved")
const fs = require("fs")
const unzipper = require("unzipper")
const { exit } = require("./util")
const { exit, asyncDownload, asyncExtract } = require("./util")

module.exports = async () => {
var link = `https://dl.issou.best/ordr/client-latest.zip`
const output = path.resolve("files/client-latest.zip")
let link = `https://dl.issou.best/ordr/client-latest.zip`
const outputZip = path.resolve("files/client-latest.zip")

let download = wget.download(link, output)
download.on("error", async err => {
console.log(err)
await exit()
})
download.on("start", fileSize => {
console.log(`Downloading the client update at ${link}, ${fileSize} bytes to download...`)
})
download.on("end", async () => {
try {
fs.createReadStream(output)
.pipe(
unzipper.Extract({
path: `.`
})
)
.on("close", async () => {
console.log(`Finished updating the client. You can now restart it.`)
await exit()
})
} catch (err) {
console.log("An error occured while unpacking: " + err)
await exit()
}
})
await asyncDownload(link, outputZip, "client-latest", "file")
await asyncExtract(outputZip, ".", "client-latest", "file")

console.log("Finished updating the client. You can now restart it.")
await exit()
}
3 changes: 1 addition & 2 deletions files/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const wget = require("wget-improved")
const AdmZip = require("adm-zip")
const fs = require("fs")
const readline = require("readline")

exports.exit = async () => {
process.stdin.setRawMode(true)
Expand Down Expand Up @@ -47,7 +46,7 @@ exports.asyncExtract = async (input, output, filename, type) => {
if (filename !== "librespeed") console.log(`Finished unpacking ${type} ${filename}.`)
resolve()
} catch (err) {
console.log("An error occured while unpacking the skin: " + err)
console.log(`An error occured while unpacking ${type}`, err)
;async () => {
this.exit()
}
Expand Down

0 comments on commit a8985a6

Please sign in to comment.