🐛 Bug fixes in update
This commit is contained in:
parent
90cd5b23a0
commit
3876d1c606
@ -89,15 +89,37 @@ export async function downloadAssets(task: InstallTask): Promise<string | undefi
|
||||
updateInstallTask(task)
|
||||
}
|
||||
|
||||
const dstPath = output + '-extract'
|
||||
|
||||
switch (asset.contentType) {
|
||||
case 'application/zip':
|
||||
const directory = await unzipper.Open.file(output)
|
||||
await directory.extract({ path: task.basePath })
|
||||
fs.unlinkSync(output)
|
||||
await directory.extract({ path: dstPath })
|
||||
break
|
||||
default:
|
||||
throw new Error('Failed to decompress, unsupported type')
|
||||
}
|
||||
|
||||
fs.unlinkSync(output)
|
||||
|
||||
function moveFiles(from: string, to: string) {
|
||||
const files = fs.readdirSync(from)
|
||||
|
||||
for (const file of files) {
|
||||
const sourcePath = path.join(from, file)
|
||||
const targetPath = path.join(to, file)
|
||||
|
||||
if (fs.statSync(sourcePath).isDirectory()) {
|
||||
moveFiles(sourcePath, targetPath)
|
||||
} else {
|
||||
fs.renameSync(sourcePath, targetPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
moveFiles(dstPath, task.basePath)
|
||||
|
||||
fs.rmSync(dstPath, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
return output
|
||||
|
@ -91,7 +91,7 @@ export function uninstallApp(id: string) {
|
||||
if (!app) return
|
||||
|
||||
const basePath = app.basePath
|
||||
fs.rmdirSync(basePath, { recursive: true })
|
||||
fs.rmSync(basePath, { recursive: true, force: true })
|
||||
|
||||
removeAppRecord(id)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user