]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/progress.go
Log handler's stdout/stderr
[nncp.git] / src / progress.go
index 62e0f01b6ff77bc44e3bb18a64ebb2d5c17281df..5ebc72bdb20b2e16df5ba53ed33bf0669f5a13b5 100644 (file)
@@ -25,7 +25,7 @@ import (
        "time"
 
        "github.com/dustin/go-humanize"
-       "go.cypherpunks.ru/nncp/v5/uilive"
+       "go.cypherpunks.ru/nncp/v7/uilive"
 )
 
 func init() {
@@ -132,16 +132,16 @@ func Progress(prefix string, les LEs) {
                }
        }
        progressBarsLock.RLock()
-       pb, exists := progressBars[pkt]
+       pb := progressBars[pkt]
        progressBarsLock.RUnlock()
-       if !exists {
+       if pb == nil {
                progressBarsLock.Lock()
                pb = ProgressBarNew(size, fullsize)
                progressBars[pkt] = pb
                progressBarsLock.Unlock()
        }
        what := pkt
-       if len(what) >= 52 { // Base32 encoded
+       if len(what) >= Base32Encoded32Len { // Base32 encoded
                what = what[:16] + ".." + what[len(what)-16:]
        }
        what = prefix + " " + what
@@ -153,3 +153,13 @@ func Progress(prefix string, les LEs) {
                progressBarsLock.Unlock()
        }
 }
+
+func ProgressKill(pkt string) {
+       progressBarsLock.Lock()
+       pb := progressBars[pkt]
+       if pb != nil {
+               pb.Kill()
+               delete(progressBars, pkt)
+       }
+       progressBarsLock.Unlock()
+}