From b682e8cf2db118ce05a639a6a096797e15bb2298 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 8 Sep 2020 17:39:47 -0700 Subject: [PATCH] vendor: bump fileutils to v0.5.0 Signed-off-by: Kir Kolyshkin --- go.mod | 2 +- go.sum | 4 +- .../github.com/mrunalp/fileutils/fileutils.go | 38 ++++++++++++------- vendor/github.com/mrunalp/fileutils/go.mod | 3 ++ vendor/modules.txt | 2 +- 5 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 vendor/github.com/mrunalp/fileutils/go.mod diff --git a/go.mod b/go.mod index c88365a36..9c83901f0 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/godbus/dbus/v5 v5.0.3 github.com/golang/protobuf v1.4.2 github.com/moby/sys/mountinfo v0.1.3 - github.com/mrunalp/fileutils v0.0.0-20200520151820-abd8a0e76976 + github.com/mrunalp/fileutils v0.5.0 github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6 github.com/opencontainers/selinux v1.6.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index b5ea07a84..1778432ce 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/moby/sys/mountinfo v0.1.3 h1:KIrhRO14+AkwKvG/g2yIpNMOUVZ02xNhOw8KY1WsLOI= github.com/moby/sys/mountinfo v0.1.3/go.mod h1:w2t2Avltqx8vE7gX5l+QiBKxODu2TX0+Syr3h52Tw4o= -github.com/mrunalp/fileutils v0.0.0-20200520151820-abd8a0e76976 h1:aZQToFSLH8ejFeSkTc3r3L4dPImcj7Ib/KgmkQqbGGg= -github.com/mrunalp/fileutils v0.0.0-20200520151820-abd8a0e76976/go.mod h1:x8F1gnqOkIEiO4rqoeEEEqQbo7HjGMTvyoq3gej4iT0= +github.com/mrunalp/fileutils v0.5.0 h1:NKzVxiH7eSk+OQ4M+ZYW1K6h27RUV3MI6NUTsHhU6Z4= +github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6 h1:NhsM2gc769rVWDqJvapK37r+7+CBXI8xHhnfnt8uQsg= github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.6.0 h1:+bIAS/Za3q5FTwWym4fTB0vObnfCf3G/NC7K6Jx62mY= diff --git a/vendor/github.com/mrunalp/fileutils/fileutils.go b/vendor/github.com/mrunalp/fileutils/fileutils.go index 136bbd9fb..7421e6207 100644 --- a/vendor/github.com/mrunalp/fileutils/fileutils.go +++ b/vendor/github.com/mrunalp/fileutils/fileutils.go @@ -22,7 +22,7 @@ func CopyFile(source string, dest string) error { uid := int(st.Uid) gid := int(st.Gid) - modeType := si.Mode()&os.ModeType + modeType := si.Mode() & os.ModeType // Handle symlinks if modeType == os.ModeSymlink { @@ -52,19 +52,7 @@ func CopyFile(source string, dest string) error { // Handle regular files if si.Mode().IsRegular() { - sf, err := os.Open(source) - if err != nil { - return err - } - defer sf.Close() - - df, err := os.Create(dest) - if err != nil { - return err - } - defer df.Close() - - _, err = io.Copy(df, sf) + err = copyInternal(source, dest) if err != nil { return err } @@ -85,6 +73,28 @@ func CopyFile(source string, dest string) error { return nil } +func copyInternal(source, dest string) (retErr error) { + sf, err := os.Open(source) + if err != nil { + return err + } + defer sf.Close() + + df, err := os.Create(dest) + if err != nil { + return err + } + defer func() { + err := df.Close() + if retErr == nil { + retErr = err + } + }() + + _, err = io.Copy(df, sf) + return err +} + // CopyDirectory copies the files under the source directory // to dest directory. The dest directory is created if it // does not exist. diff --git a/vendor/github.com/mrunalp/fileutils/go.mod b/vendor/github.com/mrunalp/fileutils/go.mod new file mode 100644 index 000000000..d8971cabc --- /dev/null +++ b/vendor/github.com/mrunalp/fileutils/go.mod @@ -0,0 +1,3 @@ +module github.com/mrunalp/fileutils + +go 1.13 diff --git a/vendor/modules.txt b/vendor/modules.txt index c3511f2a4..5e18a8e63 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -35,7 +35,7 @@ github.com/konsorten/go-windows-terminal-sequences # github.com/moby/sys/mountinfo v0.1.3 ## explicit github.com/moby/sys/mountinfo -# github.com/mrunalp/fileutils v0.0.0-20200520151820-abd8a0e76976 +# github.com/mrunalp/fileutils v0.5.0 ## explicit github.com/mrunalp/fileutils # github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6