diff --git a/main.go b/main.go index 084ac05c..12dd4bd4 100644 --- a/main.go +++ b/main.go @@ -331,7 +331,7 @@ func main() { log.Warn("检测到 auto_update.exe,即将自动退出当前程序并进行升级") log.Warn("程序目录下会出现“升级日志.log”,这代表升级正在进行中,如果失败了请检查此文件。") - err := CheckUpdater(diceManager) + err = CheckUpdater(diceManager) if err != nil { log.Error("升级程序检查失败: ", err.Error()) } else { @@ -353,7 +353,7 @@ func main() { } if doNext { - err := CheckUpdater(diceManager) + err = CheckUpdater(diceManager) if err != nil { log.Error("升级程序检查失败: ", err.Error()) } else { @@ -368,7 +368,7 @@ func main() { removeUpdateFiles() if opts.UpdateTest { - err := CheckUpdater(diceManager) + err = CheckUpdater(diceManager) if err != nil { log.Error("升级程序检查失败: ", err.Error()) } else { @@ -378,7 +378,7 @@ func main() { // 先临时放这里,后面再整理一下升级模块 diceManager.UpdateSealdiceByFile = func(packName string, log *log.Helper) bool { - err := CheckUpdater(diceManager) + err = CheckUpdater(diceManager) if err != nil { log.Error("升级程序检查失败: ", err.Error()) return false @@ -399,7 +399,8 @@ func main() { useBuiltinUI := false checkFrontendExists := func() bool { - stat, err := os.Stat("./frontend_overwrite") + var stat os.FileInfo + stat, err = os.Stat("./frontend_overwrite") return err == nil && stat.IsDir() } if !checkFrontendExists() { diff --git a/migrate/v150_attrs.go b/migrate/v150_attrs.go index ce62aeb3..4c43324e 100644 --- a/migrate/v150_attrs.go +++ b/migrate/v150_attrs.go @@ -432,10 +432,18 @@ func V150Upgrade() error { } defer func() { if p := recover(); p != nil { - tx.Rollback() + err = tx.Rollback() + if err != nil { + log.Errorf("回滚事务时出错: %v", err) + } panic(p) // 继续传播 panic } else if err != nil { - tx.Rollback() + log.Errorf("日志处理时出现异常行为: %v", err) + err = tx.Rollback() + if err != nil { + log.Errorf("回滚事务时出错: %v", err) + return + } } else { err = tx.Commit() if err != nil { @@ -464,7 +472,7 @@ func V150Upgrade() error { sheetIdBindByGroupUserId = map[string]string{} for _, singleSql := range v150sqls { - if _, err := tx.Exec(singleSql); err != nil { + if _, err = tx.Exec(singleSql); err != nil { return fmt.Errorf("执行 SQL 出错: %w", err) } }