realtime AddToDownloadList

This commit is contained in:
josc146 2023-05-21 10:55:23 +08:00
parent 825cbd15f8
commit d72144d8c8

View File

@ -86,12 +86,8 @@ func (a *App) ContinueDownload(url string) {
func (a *App) AddToDownloadList(path string, url string) { func (a *App) AddToDownloadList(path string, url string) {
if !existsInDownloadList(url) { if !existsInDownloadList(url) {
client := grab.NewClient()
req, _ := grab.NewRequest(path, url)
resp := client.Do(req)
downloadList = append(downloadList, DownloadStatus{ downloadList = append(downloadList, DownloadStatus{
resp: resp, resp: nil,
Name: filepath.Base(path), Name: filepath.Base(path),
Path: path, Path: path,
Url: url, Url: url,
@ -102,6 +98,7 @@ func (a *App) AddToDownloadList(path string, url string) {
Downloading: true, Downloading: true,
Done: false, Done: false,
}) })
a.ContinueDownload(url)
} else { } else {
a.ContinueDownload(url) a.ContinueDownload(url)
} }