mirror of
https://github.com/Xpl0itU/WiiUDownloader.git
synced 2025-06-06 17:51:21 -04:00
Improve download speeds and responsiveness
This commit is contained in:
parent
b8a397cc6c
commit
9aeb2e9f44
1 changed files with 9 additions and 3 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
const (
|
const (
|
||||||
maxRetries = 5
|
maxRetries = 5
|
||||||
retryDelay = 5 * time.Second
|
retryDelay = 5 * time.Second
|
||||||
|
bufferSize = 1048576
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProgressWindow struct {
|
type ProgressWindow struct {
|
||||||
|
@ -94,6 +95,7 @@ func downloadFile(progressWindow *ProgressWindow, client *grab.Client, downloadU
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
req.BufferSize = bufferSize
|
||||||
|
|
||||||
resp := client.Do(req)
|
resp := client.Do(req)
|
||||||
progressWindow.bar.SetFraction(resp.Progress())
|
progressWindow.bar.SetFraction(resp.Progress())
|
||||||
|
@ -112,15 +114,18 @@ func downloadFile(progressWindow *ProgressWindow, client *grab.Client, downloadU
|
||||||
glib.IdleAdd(func() {
|
glib.IdleAdd(func() {
|
||||||
progressWindow.bar.SetFraction(resp.Progress())
|
progressWindow.bar.SetFraction(resp.Progress())
|
||||||
progressWindow.bar.SetText(fmt.Sprintf("Downloading %s (%s/%s) (%s/s)", filePath, humanize.Bytes(uint64(resp.BytesComplete())), humanize.Bytes(uint64(resp.Size())), humanize.Bytes(uint64(resp.BytesPerSecond()))))
|
progressWindow.bar.SetText(fmt.Sprintf("Downloading %s (%s/%s) (%s/s)", filePath, humanize.Bytes(uint64(resp.BytesComplete())), humanize.Bytes(uint64(resp.Size())), humanize.Bytes(uint64(resp.BytesPerSecond()))))
|
||||||
for gtk.EventsPending() {
|
|
||||||
gtk.MainIteration()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
for gtk.EventsPending() {
|
||||||
|
gtk.MainIteration()
|
||||||
|
}
|
||||||
if progressWindow.cancelled {
|
if progressWindow.cancelled {
|
||||||
resp.Cancel()
|
resp.Cancel()
|
||||||
break Loop
|
break Loop
|
||||||
}
|
}
|
||||||
case <-resp.Done:
|
case <-resp.Done:
|
||||||
|
for gtk.EventsPending() {
|
||||||
|
gtk.MainIteration()
|
||||||
|
}
|
||||||
if err := resp.Err(); err != nil {
|
if err := resp.Err(); err != nil {
|
||||||
if doRetries && attempt < maxRetries {
|
if doRetries && attempt < maxRetries {
|
||||||
time.Sleep(retryDelay)
|
time.Sleep(retryDelay)
|
||||||
|
@ -156,6 +161,7 @@ func DownloadTitle(titleID string, outputDirectory string, doDecryption bool, pr
|
||||||
}
|
}
|
||||||
|
|
||||||
client := grab.NewClient()
|
client := grab.NewClient()
|
||||||
|
client.BufferSize = bufferSize
|
||||||
downloadURL := fmt.Sprintf("%s/%s", baseURL, "tmd")
|
downloadURL := fmt.Sprintf("%s/%s", baseURL, "tmd")
|
||||||
tmdPath := filepath.Join(outputDir, "title.tmd")
|
tmdPath := filepath.Join(outputDir, "title.tmd")
|
||||||
if err := downloadFile(progressWindow, client, downloadURL, tmdPath, true); err != nil {
|
if err := downloadFile(progressWindow, client, downloadURL, tmdPath, true); err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue