diff --git a/src/webrtc/pkg/session/receiver/receiver.go b/src/webrtc/pkg/session/receiver/receiver.go index cedddb78..c8521f5e 100644 --- a/src/webrtc/pkg/session/receiver/receiver.go +++ b/src/webrtc/pkg/session/receiver/receiver.go @@ -2,8 +2,10 @@ package receiver import ( "encoding/binary" + "fmt" "io" "os" + "path/filepath" "time" "github.com/mattn/go-colorable" @@ -168,6 +170,8 @@ func (s *Session) receiveData(pathToFile string, fileSize int64) error { }() firstByte := true + _, fname := filepath.Split(pathToFile) + fname = fmt.Sprintf("%10s", fname) var bar *progressbar.ProgressBar // Consume the message channel, until done // Does not stop on error @@ -194,6 +198,8 @@ func (s *Session) receiveData(pathToFile string, fileSize int64) error { if firstByte { bar = progressbar.NewOptions64( fileSize, + progressbar.OptionSetWidth(8), + progressbar.OptionSetDescription(fname), progressbar.OptionSetRenderBlankState(true), progressbar.OptionSetBytes64(fileSize), progressbar.OptionSetWriter(os.Stderr), diff --git a/src/webrtc/pkg/session/sender/sender.go b/src/webrtc/pkg/session/sender/sender.go index 3f1c6c07..68cd3835 100644 --- a/src/webrtc/pkg/session/sender/sender.go +++ b/src/webrtc/pkg/session/sender/sender.go @@ -2,6 +2,7 @@ package sender import ( "encoding/binary" + "fmt" "io" "os" "sync" @@ -185,7 +186,7 @@ func (s *Session) readFile(pathToFile string) error { } stat, _ := f.Stat() s.fileSize = stat.Size() - s.fname = stat.Name() + s.fname = fmt.Sprintf("%12s", stat.Name()) s.firstByte = true log.Debugf("Starting to read data from '%s'", pathToFile) s.readingStats.Start() @@ -253,8 +254,10 @@ func (s *Session) onBufferedAmountLow() func() { s.sess.NetworkStats.AddBytes(uint64(cur.n)) if s.firstByte { s.firstByte = false + fmt.Fprint(os.Stderr, "\n") s.bar = progressbar.NewOptions64( s.fileSize, + progressbar.OptionSetWidth(8), progressbar.OptionSetDescription(s.fname), progressbar.OptionSetRenderBlankState(true), progressbar.OptionSetBytes64(s.fileSize),