From e42744d681acfde5df8e7dd0dc25df74d5ebbe47 Mon Sep 17 00:00:00 2001 From: shine <1042864399@qq.com> Date: Sat, 12 Oct 2024 14:38:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=BB=93=E6=9D=9F=E6=97=B6=EF=BC=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E8=B5=84=E6=BA=90=E7=94=B1=E4=BA=8E=E5=8F=A5=E6=9F=84?= =?UTF-8?q?=E6=9C=AA=E9=87=8A=E6=94=BE=E5=AF=BC=E8=87=B4=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/client.go b/service/client.go index 6adf907..fc5fa8a 100644 --- a/service/client.go +++ b/service/client.go @@ -79,14 +79,13 @@ func (c *ClientService) Download(online *models.Online, uuid string, progress bi downloadFile := filepath.Join(cfg.T.CardDir, fmt.Sprintf("%s.zip", uuid)) _, err = os.Stat(downloadFile) if err == nil { - os.Remove(downloadFile) + os.RemoveAll(downloadFile) } file, err := os.Create(downloadFile) if err != nil { return err } - defer file.Close() r := Rr{ file: file, @@ -97,6 +96,7 @@ func (c *ClientService) Download(online *models.Online, uuid string, progress bi } _, err = io.Copy(&r, resp.Body) + file.Close() if err != nil { return err } @@ -106,7 +106,7 @@ func (c *ClientService) Download(online *models.Online, uuid string, progress bi if err = unzipFile(downloadFile, destDir); err != nil { return err } - _ = os.Remove(downloadFile) + _ = os.RemoveAll(downloadFile) return nil }