Clean upgrade extraction directories
This commit is contained in:
@@ -71,6 +71,7 @@ let state = readState() || {
|
||||
main().catch(error => {
|
||||
log(`fatal: ${error instanceof Error ? error.stack || error.message : String(error)}`);
|
||||
if (dryRun) {
|
||||
cleanupExtractDir();
|
||||
updateState({
|
||||
status: 'failed',
|
||||
step: 'preflight_failed',
|
||||
@@ -140,6 +141,7 @@ async function main() {
|
||||
|
||||
if (dryRun) {
|
||||
logStep('预检完成', `升级包可用于${mode === 'hot' ? '热更新' : '冷更新'},${mode === 'cold' || validation.requiresRestart ? '需要重启平台' : '无需重启平台'}`);
|
||||
cleanupExtractDir();
|
||||
updateState({
|
||||
status: 'succeeded',
|
||||
step: 'preflight_completed',
|
||||
@@ -186,6 +188,7 @@ async function main() {
|
||||
logStep('热更新验证', '正在执行 TypeScript 校验,确认补丁不会破坏现有代码');
|
||||
run('pnpm', ['run', 'ts-check'], { cwd: projectRoot, label: 'TypeScript 校验' });
|
||||
logStep('热更新完成', '升级成功,平台未重启,前端业务不中断');
|
||||
cleanupExtractDir();
|
||||
updateState({
|
||||
status: 'succeeded',
|
||||
step: 'completed',
|
||||
@@ -217,6 +220,7 @@ async function main() {
|
||||
|
||||
updateState({ step: 'restart', progress: 94, message: '构建已完成,正在后台重启平台进程' });
|
||||
logStep('冷更新完成', '升级文件已应用并完成构建,将在后台重启平台进程');
|
||||
cleanupExtractDir();
|
||||
updateState({
|
||||
status: 'succeeded',
|
||||
step: 'completed',
|
||||
@@ -266,6 +270,7 @@ async function rollbackAfterFailure(message) {
|
||||
}
|
||||
|
||||
logStep('自动回滚完成', '升级失败,但已自动恢复到升级开始前状态');
|
||||
cleanupExtractDir();
|
||||
updateState({
|
||||
status: 'rolled_back',
|
||||
step: 'rolled_back',
|
||||
@@ -358,6 +363,12 @@ function resetDir(dir) {
|
||||
ensureDir(dir);
|
||||
}
|
||||
|
||||
function cleanupExtractDir() {
|
||||
if (!fs.existsSync(extractDir)) return;
|
||||
fs.rmSync(extractDir, { recursive: true, force: true });
|
||||
logStep('清理解压目录', `已删除临时目录:${extractDir}`);
|
||||
}
|
||||
|
||||
function run(command, commandArgs, options = {}) {
|
||||
runCapture(command, commandArgs, options);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user