diff options
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/fetcher.go | 16 | ||||
-rw-r--r-- | rhimport/session.go | 1 |
2 files changed, 15 insertions, 2 deletions
diff --git a/rhimport/fetcher.go b/rhimport/fetcher.go index 5779631..0b1c3b2 100644 --- a/rhimport/fetcher.go +++ b/rhimport/fetcher.go @@ -368,15 +368,27 @@ func fetchFileFake(ctx *Context, res *Result, uri *url.URL) error { } func writeAttachmentFile(ctx *Context, res *Result, sizeTotal uint64, src *os.File) error { + cancel := ctx.Cancel + if cancel == nil { + cancel = make(<-chan bool) + } + written := 0 for { select { - case <-ctx.Cancel: + case <-cancel: rhl.Printf("receiving attachment '%s' got canceled", ctx.SourceFile) res.ResponseCode = http.StatusNoContent res.ErrorString = "canceled" return nil - case data := <-ctx.AttachmentChan: + case data, ok := <-ctx.AttachmentChan: + if !ok { + rhl.Printf("receiving attachment '%s' got canceled (channel has been closed)", ctx.SourceFile) + res.ResponseCode = http.StatusNoContent + res.ErrorString = "canceled" + return nil + } + w, err := src.Write(data) if err != nil { rhl.Printf("Unable to write file %s: %s", ctx.SourceFile, err) diff --git a/rhimport/session.go b/rhimport/session.go index e04066a..84d283e 100644 --- a/rhimport/session.go +++ b/rhimport/session.go @@ -221,6 +221,7 @@ func (self *Session) dispatchRequests() { if progressPending > 1 && lastProgress != nil { self.callProgressHandler(lastProgress) } + progressPending = 0 lastProgress = nil case p := <-self.progressIntChan: if self.state == SESSION_RUNNING { |