mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
Progress during publishing.
This commit is contained in:
@@ -13,11 +13,13 @@ const (
|
||||
codeProgress
|
||||
codeHideProgress
|
||||
codeStop
|
||||
codeFlush
|
||||
)
|
||||
|
||||
type printTask struct {
|
||||
code int
|
||||
message string
|
||||
reply chan bool
|
||||
}
|
||||
|
||||
// Progress is a progress displaying subroutine, it allows to show download and other operations progress
|
||||
@@ -55,6 +57,13 @@ func (p *Progress) Shutdown() {
|
||||
<-p.stopped
|
||||
}
|
||||
|
||||
// Flush waits for all queued messages to be displayed
|
||||
func (p *Progress) Flush() {
|
||||
ch := make(chan bool)
|
||||
p.queue <- printTask{code: codeFlush, reply: ch}
|
||||
<-ch
|
||||
}
|
||||
|
||||
// InitBar starts progressbar for count bytes or count items
|
||||
func (p *Progress) InitBar(count int64, isBytes bool) {
|
||||
if p.bar != nil {
|
||||
@@ -161,6 +170,8 @@ func (p *Progress) worker() {
|
||||
fmt.Print("\r\033[2K")
|
||||
p.barShown = false
|
||||
}
|
||||
case codeFlush:
|
||||
task.reply <- true
|
||||
case codeStop:
|
||||
p.stopped <- true
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user