From 6876f28505fd3cea4cade726f28ecca45ed524f2 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 19 Sep 2023 17:20:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0=20(#2349)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/snapshot.go | 5 +++-- backend/app/service/upgrade.go | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/app/service/snapshot.go b/backend/app/service/snapshot.go index ebb80ddc7..c3cd0e196 100644 --- a/backend/app/service/snapshot.go +++ b/backend/app/service/snapshot.go @@ -884,9 +884,10 @@ func updateRollbackStatus(id uint, status string, message string) { } func cpBinary(src []string, dst string) error { - stderr, err := cmd.Exec(fmt.Sprintf("\\cp -f %s %s", strings.Join(src, " "), dst)) + global.LOG.Debugf(fmt.Sprintf("\\cp -f %s %s", strings.Join(src, " "), dst)) + stdout, err := cmd.Exec(fmt.Sprintf("\\cp -f %s %s", strings.Join(src, " "), dst)) if err != nil { - return errors.New(stderr) + return fmt.Errorf("cp file failed, stdout: %v, err: %v", stdout, err) } return nil } diff --git a/backend/app/service/upgrade.go b/backend/app/service/upgrade.go index 2a3daf0d7..952831032 100644 --- a/backend/app/service/upgrade.go +++ b/backend/app/service/upgrade.go @@ -132,25 +132,25 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error { global.LOG.Info("backup original data successful, now start to upgrade!") if err := cpBinary([]string{tmpDir + "/1panel"}, "/usr/local/bin/1panel"); err != nil { - u.handleRollback(fileOp, originalDir, 1) global.LOG.Errorf("upgrade 1panel failed, err: %v", err) + u.handleRollback(fileOp, originalDir, 1) return } if err := cpBinary([]string{tmpDir + "/1pctl"}, "/usr/local/bin/1pctl"); err != nil { - u.handleRollback(fileOp, originalDir, 2) global.LOG.Errorf("upgrade 1pctl failed, err: %v", err) + u.handleRollback(fileOp, originalDir, 2) return } if _, err := cmd.Execf("sed -i -e 's#BASE_DIR=.*#BASE_DIR=%s#g' /usr/local/bin/1pctl", global.CONF.System.BaseDir); err != nil { - u.handleRollback(fileOp, originalDir, 2) global.LOG.Errorf("upgrade basedir in 1pctl failed, err: %v", err) + u.handleRollback(fileOp, originalDir, 2) return } if err := cpBinary([]string{tmpDir + "/1panel.service"}, "/etc/systemd/system/1panel.service"); err != nil { - u.handleRollback(fileOp, originalDir, 3) global.LOG.Errorf("upgrade 1panel.service failed, err: %v", err) + u.handleRollback(fileOp, originalDir, 3) return }