]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/progress.go
Prefixed progress messages
[nncp.git] / src / progress.go
index d07185749dd812670e156fb1ff800444c2c3ad0d..4474cf5adfe200f0c95b8a3abb93dcc025b14c92 100644 (file)
@@ -21,7 +21,6 @@ import (
        "fmt"
        "io"
        "os"
-       "strings"
        "sync"
        "time"
 
@@ -82,6 +81,7 @@ func (pb ProgressBar) Kill() {
 func CopyProgressed(
        dst io.Writer,
        src io.Reader,
+       prgrsPrefix string,
        sds SDS,
        showPrgrs bool,
 ) (written int64, err error) {
@@ -96,7 +96,7 @@ func CopyProgressed(
                                written += int64(nw)
                                if showPrgrs {
                                        sds["size"] = written
-                                       Progress(sds)
+                                       Progress(prgrsPrefix, sds)
                                }
                        }
                        if ew != nil {
@@ -118,13 +118,13 @@ func CopyProgressed(
        return
 }
 
-func Progress(sds SDS) {
-       pkt := sds["pkt"].(string)
+func Progress(prefix string, sds SDS) {
        var size int64
        if sizeI, exists := sds["size"]; exists {
                size = sizeI.(int64)
        }
        fullsize := sds["fullsize"].(int64)
+       pkt := sds["pkt"].(string)
        progressBarsLock.RLock()
        pb, exists := progressBars[pkt]
        progressBarsLock.RUnlock()
@@ -138,9 +138,7 @@ func Progress(sds SDS) {
        if len(what) >= 52 { // Base32 encoded
                what = what[:16] + ".." + what[len(what)-16:]
        }
-       if xx, exists := sds["xx"]; exists {
-               what = strings.Title(xx.(string)) + " " + what
-       }
+       what = prefix + " " + what
        pb.Render(what, size)
        if size >= fullsize {
                pb.Kill()