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 }