From ede72365cfcec77bd3aba2ffeaa0aeb154b3e9de Mon Sep 17 00:00:00 2001 From: RicheyJang <773602577@qq.com> Date: Fri, 8 Jul 2022 16:48:53 +0800 Subject: [PATCH] fix: can not delete old file at unix --- plugins/inspection/init.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/inspection/init.go b/plugins/inspection/init.go index d05a4d2..475bc42 100644 --- a/plugins/inspection/init.go +++ b/plugins/inspection/init.go @@ -173,8 +173,10 @@ func updateHandler(ctx *zero.Ctx) { // 关闭当前进程,启动指定可执行文件继续执行 func rebirthTo(path string) { + proxy.GetLevelDB().Close() + proc := exec.Command(path, os.Args[1:]...) - //proc.Stdin = os.Stdin + proc.Stdin = os.Stdin proc.Stderr = os.Stderr proc.Stdout = os.Stdout err := proc.Start() @@ -196,7 +198,6 @@ func rebirthTo(path string) { func deleteOldBinary() { nowPath := os.Args[0] nowName := filepath.Base(nowPath) - nowExt := filepath.Ext(nowPath) lastIndex := strings.LastIndex(nowName, versionSeparator) if lastIndex <= 0 { return @@ -206,8 +207,7 @@ func deleteOldBinary() { files, _ := os.ReadDir(".") for _, file := range files { fileInfo, _ := file.Info() - if isExecutable(fileInfo) && file.Name() != nowName && - filepath.Ext(file.Name()) == nowExt && strings.HasPrefix(file.Name(), deletePrefix) { + if isExecutable(fileInfo) && file.Name() != nowName && strings.HasPrefix(file.Name(), deletePrefix) { err := os.RemoveAll(filepath.Join(".", file.Name())) if err != nil { log.Errorf("删除旧版本文件(%v) error: %v", file.Name(), err)