修复了下载工具结束时,删除资源由于句柄未释放导致删除失败
This commit is contained in:
+3
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user