From c5e13428d42d0dbad48db2dba9540074e94a75a5 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Wed, 13 Dec 2023 16:12:31 +0000 Subject: [PATCH] internal/mod/modcache: use robustio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roger Peppe Change-Id: If242aa1cdf7ca3b2c7e6e7d76339ca0c59b39ce2 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1173558 Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí TryBot-Result: CUEcueckoo --- go.mod | 2 +- go.sum | 4 ++-- internal/e2e/go.mod | 2 +- internal/e2e/go.sum | 4 ++-- internal/mod/modcache/cache.go | 7 +++---- internal/mod/modcache/fetch.go | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 33adec37bd3..6e8ea1b928e 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0-rc4 github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0 - github.com/rogpeppe/go-internal v1.11.1-0.20231026093722-fa6a31e0812c + github.com/rogpeppe/go-internal v1.12.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/tetratelabs/wazero v1.0.2 diff --git a/go.sum b/go.sum index f3f0afcdfbc..16ad255581b 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0 h1:sadMIsgmHpEOGbUs6VtHBXRR1OHevnj7hLx9ZcdNGW4= github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.11.1-0.20231026093722-fa6a31e0812c h1:fPpdjePK1atuOg28PXfNSqgwf9I/qD1Hlo39JFwKBXk= -github.com/rogpeppe/go-internal v1.11.1-0.20231026093722-fa6a31e0812c/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= diff --git a/internal/e2e/go.mod b/internal/e2e/go.mod index 76ec561243e..769f251b5bb 100644 --- a/internal/e2e/go.mod +++ b/internal/e2e/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( cuelang.org/go v0.0.0-00010101000000-000000000000 github.com/google/go-github/v56 v56.0.0 - github.com/rogpeppe/go-internal v1.11.1-0.20231026093722-fa6a31e0812c + github.com/rogpeppe/go-internal v1.12.0 github.com/rogpeppe/retry v0.1.0 ) diff --git a/internal/e2e/go.sum b/internal/e2e/go.sum index 1d80ed695a3..549f212f448 100644 --- a/internal/e2e/go.sum +++ b/internal/e2e/go.sum @@ -32,8 +32,8 @@ github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYB github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0 h1:sadMIsgmHpEOGbUs6VtHBXRR1OHevnj7hLx9ZcdNGW4= github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= -github.com/rogpeppe/go-internal v1.11.1-0.20231026093722-fa6a31e0812c h1:fPpdjePK1atuOg28PXfNSqgwf9I/qD1Hlo39JFwKBXk= -github.com/rogpeppe/go-internal v1.11.1-0.20231026093722-fa6a31e0812c/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/rogpeppe/retry v0.1.0 h1:6km4oqeZcFrnhx+PCPg/YxV3fnTdROBNVlSl8Pe/ztU= github.com/rogpeppe/retry v0.1.0/go.mod h1:/PtRtl9qXn+Pv5S4wN+Y5nusihQeI1PJ9U7KDcKzuvI= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= diff --git a/internal/mod/modcache/cache.go b/internal/mod/modcache/cache.go index 26292abf0d2..05a71c11f8a 100644 --- a/internal/mod/modcache/cache.go +++ b/internal/mod/modcache/cache.go @@ -9,6 +9,7 @@ import ( "path/filepath" "github.com/rogpeppe/go-internal/lockedfile" + "github.com/rogpeppe/go-internal/robustio" "cuelang.org/go/internal/mod/module" ) @@ -39,8 +40,7 @@ func (c *cache) readDiskCache(ctx context.Context, mv module.Version, suffix str if err != nil { return "", nil, errNotCached } - // TODO robustio.ReadFile - data, err = os.ReadFile(file) + data, err = robustio.ReadFile(file) if err != nil { return file, nil, errNotCached } @@ -80,8 +80,7 @@ func (c *cache) writeDiskCache(ctx context.Context, file string, data []byte) er if err := f.Close(); err != nil { return err } - // TODO robustio.Rename - if err := os.Rename(f.Name(), file); err != nil { + if err := robustio.Rename(f.Name(), file); err != nil { return err } return nil diff --git a/internal/mod/modcache/fetch.go b/internal/mod/modcache/fetch.go index 99391f9d5e4..9ef9dd7dfff 100644 --- a/internal/mod/modcache/fetch.go +++ b/internal/mod/modcache/fetch.go @@ -14,6 +14,7 @@ import ( "strings" "cuelabs.dev/go/oci/ociregistry" + "github.com/rogpeppe/go-internal/robustio" "cuelang.org/go/internal/mod/internal/par" "cuelang.org/go/internal/mod/modfile" @@ -331,8 +332,7 @@ func RemoveAll(dir string) error { } return nil }) - // TODO robustio.Removeall - return os.RemoveAll(dir) + return robustio.RemoveAll(dir) } // quoteGlob returns s with all Glob metacharacters quoted.