Skip to content

Commit 2c77ffc

Browse files
authored
Merge pull request #2933 from nirs/convert-interface
Update go-qcow2reader to 0.6.0
2 parents 9248baf + a65b114 commit 2c77ffc

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/google/go-cmp v0.6.0
2626
github.com/google/yamlfmt v0.14.0
2727
github.com/invopop/jsonschema v0.12.0
28-
github.com/lima-vm/go-qcow2reader v0.4.0
28+
github.com/lima-vm/go-qcow2reader v0.6.0
2929
github.com/lima-vm/sshocker v0.3.4
3030
github.com/mattn/go-isatty v0.0.20
3131
github.com/mattn/go-shellwords v1.0.12

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
179179
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
180180
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
181181
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
182-
github.com/lima-vm/go-qcow2reader v0.4.0 h1:8tQp6azEvJLwktGMv4jOaFIq2sj5VX6EFX/UluKPzNM=
183-
github.com/lima-vm/go-qcow2reader v0.4.0/go.mod h1:ay45SlGOzU+2Vc21g5/lmQgPn7Hmf0JpPhm8cuOK1FI=
182+
github.com/lima-vm/go-qcow2reader v0.6.0 h1:dNstUGQxEUPbmiiVnu/cek2x7scrHe2VJy5JseLLflo=
183+
github.com/lima-vm/go-qcow2reader v0.6.0/go.mod h1:ay45SlGOzU+2Vc21g5/lmQgPn7Hmf0JpPhm8cuOK1FI=
184184
github.com/lima-vm/sshocker v0.3.4 h1:5rn6vMkfqwZSZiBW+Udo505OIRhPB4xbLUDdEnFgWwI=
185185
github.com/lima-vm/sshocker v0.3.4/go.mod h1:QT4c7XNmeQTv79h5/8EgiS7U51B9BLenlXV7idCY0tE=
186186
github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2 h1:DZMFueDbfz6PNc1GwDRA8+6lBx1TB9UnxDQliCqR73Y=

pkg/downloader/downloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
var HideProgress bool
3131

3232
// hideBar is used only for testing.
33-
func hideBar(bar *pb.ProgressBar) {
33+
func hideBar(bar *progressbar.ProgressBar) {
3434
bar.Set(pb.Static, true)
3535
}
3636

pkg/nativeimgutil/nativeimgutil.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,8 @@ func ConvertToRaw(source, dest string, size *int64, allowSourceWithBackingFile b
7878
if err != nil {
7979
return err
8080
}
81-
conv, err := convert.New(convert.Options{})
82-
if err != nil {
83-
return err
84-
}
8581
bar.Start()
86-
pra := progressbar.ProxyReaderAt{ReaderAt: srcImg, Bar: bar}
87-
err = conv.Convert(destTmpF, &pra, srcImg.Size())
82+
err = convert.Convert(destTmpF, srcImg, convert.Options{Progress: bar})
8883
bar.Finish()
8984
if err != nil {
9085
return fmt.Errorf("failed to convert image: %w", err)

pkg/progressbar/progressbar.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package progressbar
22

33
import (
4-
"io"
54
"os"
65
"time"
76

@@ -10,19 +9,17 @@ import (
109
"github.com/sirupsen/logrus"
1110
)
1211

13-
type ProxyReaderAt struct {
14-
io.ReaderAt
15-
Bar *pb.ProgressBar
12+
// ProgressBar adapts pb.ProgressBar to go-qcow2reader.convert.Updater interface.
13+
type ProgressBar struct {
14+
*pb.ProgressBar
1615
}
1716

18-
func (r *ProxyReaderAt) ReadAt(p []byte, off int64) (int, error) {
19-
n, err := r.ReaderAt.ReadAt(p, off)
20-
r.Bar.Add(n)
21-
return n, err
17+
func (b *ProgressBar) Update(n int64) {
18+
b.Add64(n)
2219
}
2320

24-
func New(size int64) (*pb.ProgressBar, error) {
25-
bar := pb.New64(size)
21+
func New(size int64) (*ProgressBar, error) {
22+
bar := &ProgressBar{pb.New64(size)}
2623

2724
bar.Set(pb.Bytes, true)
2825

0 commit comments

Comments
 (0)