Skip to content

Commit

Permalink
Print current and total layers
Browse files Browse the repository at this point in the history
  • Loading branch information
mafredri committed May 23, 2024
1 parent 612954f commit b68a9f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ func GetFSFromLayers(root string, layers []v1.Layer, opts ...FSOpt) ([]string, e
var extractedBytes int64
for i, l := range layers {
if mediaType, err := l.MediaType(); err == nil {
logrus.Tracef("Extracting layer %d of media type %s", i, mediaType)
logrus.Tracef("Extracting layer %d/%d of media type %s", i+1, len(layers), mediaType)
} else {
logrus.Tracef("Extracting layer %d", i)
logrus.Tracef("Extracting layer %d/%d", i+1, len(layers))
}

progressPerc := float64(extractedBytes) / float64(totalSize) * 100
if printExtractionProgress {
logrus.Infof("Extracting layer %d (%.1f%%)", i, progressPerc)
logrus.Infof("Extracting layer %d/%d (%.1f%%)", i+1, len(layers), progressPerc)
}

r, err := l.Uncompressed()
Expand All @@ -214,7 +214,7 @@ func GetFSFromLayers(root string, layers []v1.Layer, opts ...FSOpt) ([]string, e
ReadCloser: r,
after: time.Second,
print: func(n int) {
logrus.Infof("Extracting layer %d (%.1f%%) %s", i, progressPerc, strings.Repeat(".", n))
logrus.Infof("Extracting layer %d/%d (%.1f%%) %s", i+1, len(layers), progressPerc, strings.Repeat(".", n))
},
}
}
Expand Down

0 comments on commit b68a9f6

Please sign in to comment.