diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-21 21:41:22 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-21 21:41:22 (GMT) |
commit | b917755aab166ebb59ebdb5356114d373ce5cb91 (patch) | |
tree | 72d74a4a8989e0ba3cde5f83bd08ffb00bdde446 /src/helsinki.at/rhimport/fetcher.go | |
parent | 0912ca15a61bc9eba102fc967367f8c1665842dc (diff) |
improved error handling and reporting, canceling running requests when telnet client leaves
Diffstat (limited to 'src/helsinki.at/rhimport/fetcher.go')
-rw-r--r-- | src/helsinki.at/rhimport/fetcher.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/helsinki.at/rhimport/fetcher.go b/src/helsinki.at/rhimport/fetcher.go index 24635d1..1f0b364 100644 --- a/src/helsinki.at/rhimport/fetcher.go +++ b/src/helsinki.at/rhimport/fetcher.go @@ -116,6 +116,7 @@ func FetchFileCurl(ctx *ImportContext, res *FetchResult, uri *url.URL) (err erro easy.Setopt(curl.OPT_NOPROGRESS, false) easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, userdata interface{}) bool { if ctx.Cancel != nil && len(ctx.Cancel) > 0 { + rhl.Printf("downloading '%s' got canceled", ctx.SourceUri) res.ResponseCode = http.StatusNoContent res.ErrorString = "canceled" return false @@ -129,6 +130,11 @@ func FetchFileCurl(ctx *ImportContext, res *FetchResult, uri *url.URL) (err erro easy.Setopt(curl.OPT_PROGRESSDATA, ctx) if err = easy.Perform(); err != nil { + if cbdata.File != nil { + rhdl.Printf("Removing stale file: %s", cbdata.filename) + os.Remove(cbdata.filename) + os.Remove(path.Dir(cbdata.filename)) + } if res.ResponseCode == http.StatusNoContent { err = nil } else { @@ -176,6 +182,7 @@ func FetchFileFake(ctx *ImportContext, res *FetchResult, uri *url.URL) error { } else { for i := uint(0); i < uint(duration); i++ { if ctx.Cancel != nil && len(ctx.Cancel) > 0 { + rhl.Printf("faking got canceled") res.ResponseCode = http.StatusNoContent res.ErrorString = "canceled" return nil |