Merge pull request #9752 from afbjorklund/download-ellipsis

Abbreviate too long filenames to show progress
pull/9702/head
Medya Ghazizadeh 2020-11-20 14:31:08 -08:00 committed by GitHub
commit 61abd1e64c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -47,7 +47,13 @@ func (cpb *progressBar) TrackProgress(src string, currentSize, totalSize int64,
cpb.progress = pb.New64(totalSize)
}
p := pb.Full.Start64(totalSize)
p.Set("prefix", " > "+filepath.Base(src+": "))
fn := filepath.Base(src)
// abbreviate filename for progress
maxwidth := 30 - len("...")
if len(fn) > maxwidth {
fn = fn[0:maxwidth] + "..."
}
p.Set("prefix", " > "+fn+": ")
p.SetCurrent(currentSize)
p.Set(pb.Bytes, true)