Skip to content

Commit a437fad

Browse files
authored
Merge pull request #119 from setlog/feature/logprogress
2 parents b68950b + 6be25e8 commit a437fad

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.4.5 (TBD)
44
### Changes
55
* Shorter log-output for proxy detection. Reduces size of the log output by 5–15%.
6+
* trivrost will log the progress of downloads if the connection was interrupted for any reason.
67
* Update most dependencies:
78
* gopsutils: v2.19.4 -> v2.20.3
89
* testify: v1.4.0 -> v1.5.1

cmd/bundown/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func downloadBundles(deploymentConfig *config.DeploymentConfig, outDirPath strin
4949
if err != nil {
5050
fatalf("%v", err)
5151
}
52-
updater := bundle.NewUpdaterWithDeploymentConfig(context.Background(), deploymentConfig, &fetching.ConsoleDownloadPogressHandler{}, resources.PublicRsaKeys)
52+
updater := bundle.NewUpdaterWithDeploymentConfig(context.Background(), deploymentConfig, &fetching.ConsoleDownloadProgressHandler{}, resources.PublicRsaKeys)
5353
for _, bundle := range deploymentConfig.Bundles {
5454
if shouldDownloadBundle(bundle.Tags, tags) {
5555
log.Infof("Starting download of bundle %s", bundle.BaseURL)

cmd/launcher/gui/gui_progress_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ func (handler *GuiDownloadProgressHandler) HandleBadHttpResponse(fromURL string,
8383
NotifyProblem(fmt.Sprintf("HTTP Status %d", code), false)
8484
}
8585

86-
func (handler *GuiDownloadProgressHandler) HandleReadError(fromURL string, err error) {
87-
log.Warnf("GET %s interrupted: %v.", fromURL, err)
86+
func (handler *GuiDownloadProgressHandler) HandleReadError(fromURL string, err error, receivedByteCount int64) {
87+
log.Warnf("GET %s interrupted after receiving %d bytes: %v.", fromURL, receivedByteCount, err)
8888
handler.progressMutex.Lock()
8989
defer handler.progressMutex.Unlock()
9090
handler.problemUrl = fromURL

pkg/fetching/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (dl *Download) readFromResponse(p []byte) (n int, err error) {
204204
dl.cleanUp() // Note: https://github.com/golang/go/issues/26095#issuecomment-400903313
205205
dl.response = nil
206206
if err != io.EOF { // Network failures are temporary. Keep trying until it works.
207-
dl.handler.HandleReadError(dl.url, err)
207+
dl.handler.HandleReadError(dl.url, err, dl.firstByteIndex)
208208
return n, nil
209209
}
210210
if (dl.lastByteIndex >= 0) && (dl.firstByteIndex < dl.lastByteIndex+1) {

pkg/fetching/downloader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (handler *ErrorRecordingHandler) HandleBadHttpResponse(fromURL string, code
3939
handler.ErrChan <- fmt.Errorf("HTTP %d: %s", code, http.StatusText(code))
4040
}
4141

42-
func (handler *ErrorRecordingHandler) HandleReadError(fromURL string, err error) {
42+
func (handler *ErrorRecordingHandler) HandleReadError(fromURL string, err error, receivedByteCount int64) {
4343
handler.ErrChan <- err
4444
}
4545

pkg/fetching/handler.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,37 @@ type DownloadProgressHandler interface {
1818

1919
HandleHttpGetError(fromURL string, err error) // The HTTP GET request to download the resource did not receive an HTTP response.
2020
HandleBadHttpResponse(fromURL string, code int) // A bad HTTP response code was received.
21-
HandleReadError(fromURL string, err error) // An error occurred while reading the response body (data) of the resource at the given URL.
21+
HandleReadError(fromURL string, err error, firstByteIndex int64) // An error occurred while reading the response body (data) of the resource at the given URL.
2222
}
2323

24-
type ConsoleDownloadPogressHandler struct {
24+
type ConsoleDownloadProgressHandler struct {
2525
}
2626

27-
func (handler *ConsoleDownloadPogressHandler) HandleProgress(fromURL string, workerId int, receivedBytes uint64) {
27+
func (handler *ConsoleDownloadProgressHandler) HandleProgress(fromURL string, workerId int, receivedBytes uint64) {
2828
}
2929

30-
func (handler *ConsoleDownloadPogressHandler) HandleStartDownload(fromURL string, workerId int) {
30+
func (handler *ConsoleDownloadProgressHandler) HandleStartDownload(fromURL string, workerId int) {
3131
log.Infof("Downloading %s", fromURL)
3232
}
3333

34-
func (handler *ConsoleDownloadPogressHandler) HandleFinishDownload(fromURL string, workerId int) {
34+
func (handler *ConsoleDownloadProgressHandler) HandleFinishDownload(fromURL string, workerId int) {
3535
}
3636

37-
func (handler *ConsoleDownloadPogressHandler) HandleFailDownload(fromURL string, workerId int, err error) {
37+
func (handler *ConsoleDownloadProgressHandler) HandleFailDownload(fromURL string, workerId int, err error) {
3838
}
3939

40-
func (handler *ConsoleDownloadPogressHandler) HandleHttpGetError(fromURL string, err error) {
40+
func (handler *ConsoleDownloadProgressHandler) HandleHttpGetError(fromURL string, err error) {
4141
log.Errorf("Error downloading %s: %v.", fromURL, err)
4242
os.Exit(1)
4343
}
4444

45-
func (handler *ConsoleDownloadPogressHandler) HandleBadHttpResponse(fromURL string, code int) {
45+
func (handler *ConsoleDownloadProgressHandler) HandleBadHttpResponse(fromURL string, code int) {
4646
log.Errorf("GET %s yielded bad HTTP response: %v (Code was %d)", fromURL, http.StatusText(code), code)
4747
os.Exit(1)
4848
}
4949

50-
func (handler *ConsoleDownloadPogressHandler) HandleReadError(fromURL string, err error) {
51-
log.Errorf("Could not copy bytes from \"%s\": %v", fromURL, err)
50+
func (handler *ConsoleDownloadProgressHandler) HandleReadError(fromURL string, err error, receivedByteCount int64) {
51+
log.Errorf("Could not copy bytes from \"%s\" (failed after %d bytes): %v", fromURL, receivedByteCount, err)
5252
os.Exit(1)
5353
}
5454

@@ -73,5 +73,5 @@ func (handler *EmptyHandler) HandleHttpGetError(fromURL string, err error) {
7373
func (handler *EmptyHandler) HandleBadHttpResponse(fromURL string, code int) {
7474
}
7575

76-
func (handler *EmptyHandler) HandleReadError(fromURL string, err error) {
76+
func (handler *EmptyHandler) HandleReadError(fromURL string, err error, receivedByteCount int64) {
7777
}

0 commit comments

Comments
 (0)