🐛 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)
|
updateInstallTask(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dstPath = output + '-extract'
|
||||||
|
|
||||||
switch (asset.contentType) {
|
switch (asset.contentType) {
|
||||||
case 'application/zip':
|
case 'application/zip':
|
||||||
const directory = await unzipper.Open.file(output)
|
const directory = await unzipper.Open.file(output)
|
||||||
await directory.extract({ path: task.basePath })
|
await directory.extract({ path: dstPath })
|
||||||
fs.unlinkSync(output)
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new Error('Failed to decompress, unsupported type')
|
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
|
return output
|
||||||
|
@ -91,7 +91,7 @@ export function uninstallApp(id: string) {
|
|||||||
if (!app) return
|
if (!app) return
|
||||||
|
|
||||||
const basePath = app.basePath
|
const basePath = app.basePath
|
||||||
fs.rmdirSync(basePath, { recursive: true })
|
fs.rmSync(basePath, { recursive: true, force: true })
|
||||||
|
|
||||||
removeAppRecord(id)
|
removeAppRecord(id)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user