fix(deps): update module github.com/crc-org/crc/v2 to v2.45.0

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2024-12-11 09:51:52 +00:00
committed by GitHub
parent 58bbe14d2e
commit c11fd6562d
4 changed files with 30 additions and 19 deletions

2
go.mod
View File

@@ -24,7 +24,7 @@ require (
github.com/containers/storage v1.56.0
github.com/containers/winquit v1.1.0
github.com/coreos/go-systemd/v22 v22.5.1-0.20231103132048-7d375ecc2b09
github.com/crc-org/crc/v2 v2.44.0
github.com/crc-org/crc/v2 v2.45.0
github.com/crc-org/vfkit v0.6.0
github.com/cyphar/filepath-securejoin v0.3.4
github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e

4
go.sum
View File

@@ -107,8 +107,8 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7
github.com/coreos/go-systemd/v22 v22.5.1-0.20231103132048-7d375ecc2b09 h1:OoRAFlvDGCUqDLampLQjk0yeeSGdF9zzst/3G9IkBbc=
github.com/coreos/go-systemd/v22 v22.5.1-0.20231103132048-7d375ecc2b09/go.mod h1:m2r/smMKsKwgMSAoFKHaa68ImdCSNuKE1MxvQ64xuCQ=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/crc-org/crc/v2 v2.44.0 h1:GQ/GeBvlnFIIWxZLAL5c9HH9Uwur8hTthPUbOp1d++M=
github.com/crc-org/crc/v2 v2.44.0/go.mod h1:EMiQkkpN4y6j4S2FwUlcm1pi4j0YFqir7a6uJthO75Q=
github.com/crc-org/crc/v2 v2.45.0 h1:7rScVQwFc3oy99SaiGSgQmTiIQf7UKKYIcZQ963NsdE=
github.com/crc-org/crc/v2 v2.45.0/go.mod h1:ALUixzv85cMYNDEqone8jEn3m2ZKyu9oRzrQdEAjnzk=
github.com/crc-org/vfkit v0.6.0 h1:gUasCX2QqY9pUPebFhYsuINB8XSS/iz0qy4v18CUyB4=
github.com/crc-org/vfkit v0.6.0/go.mod h1:i+fGyDMg5MpuUYCFXc2VXw+5R7MBD6A/8xU9UxWv/9s=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=

View File

@@ -2,6 +2,7 @@ package os
import (
"bytes"
"context"
"io"
"os"
)
@@ -22,7 +23,7 @@ func copyFile(src, dst string, sparse bool) error {
defer out.Close()
if sparse {
if _, err = CopySparse(out, in); err != nil {
if _, err = CopySparse(context.TODO(), out, in); err != nil {
return err
}
} else {
@@ -51,9 +52,13 @@ func CopyFileSparse(src, dst string) error {
return copyFile(src, dst, true)
}
func CopySparse(dst io.WriteSeeker, src io.Reader) (int64, error) {
func CopySparse(ctx context.Context, dst io.WriteSeeker, src io.Reader) (int64, error) {
copyBuf := make([]byte, copyChunkSize)
sparseWriter := newSparseWriter(dst)
if ctx == nil {
panic("ctx is nil, this should not happen")
}
sparseWriter := newSparseWriter(ctx, dst)
bytesWritten, err := io.CopyBuffer(sparseWriter, src, copyBuf)
if err != nil {
@@ -64,12 +69,13 @@ func CopySparse(dst io.WriteSeeker, src io.Reader) (int64, error) {
}
type sparseWriter struct {
context context.Context
writer io.WriteSeeker
lastChunkSparse bool
}
func newSparseWriter(writer io.WriteSeeker) *sparseWriter {
return &sparseWriter{writer: writer}
func newSparseWriter(ctx context.Context, writer io.WriteSeeker) *sparseWriter {
return &sparseWriter{context: ctx, writer: writer}
}
const copyChunkSize = 4096
@@ -84,6 +90,10 @@ func isEmptyChunk(p []byte) bool {
}
func (w *sparseWriter) Write(p []byte) (n int, err error) {
select {
case <-w.context.Done(): // Context cancelled
return 0, w.context.Err()
default:
if isEmptyChunk(p) {
offset, err := w.writer.Seek(int64(len(p)), io.SeekCurrent)
if err != nil {
@@ -96,6 +106,7 @@ func (w *sparseWriter) Write(p []byte) (n int, err error) {
}
w.lastChunkSparse = false
return w.writer.Write(p)
}
}
func (w *sparseWriter) Close() error {

2
vendor/modules.txt vendored
View File

@@ -427,7 +427,7 @@ github.com/coreos/go-systemd/v22/dbus
github.com/coreos/go-systemd/v22/internal/dlopen
github.com/coreos/go-systemd/v22/journal
github.com/coreos/go-systemd/v22/sdjournal
# github.com/crc-org/crc/v2 v2.44.0
# github.com/crc-org/crc/v2 v2.45.0
## explicit; go 1.22.0
github.com/crc-org/crc/v2/pkg/crc/logging
github.com/crc-org/crc/v2/pkg/os