From 0f11646a6619c14927a53b4650479852cfa7df4f Mon Sep 17 00:00:00 2001 From: Nicolas JUHEL Date: Mon, 12 Oct 2020 01:13:41 +0200 Subject: [PATCH 1/3] Fix mode file open write/create --- ioutils/fileProgess.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ioutils/fileProgess.go b/ioutils/fileProgess.go index 468a4092..68d10589 100644 --- a/ioutils/fileProgess.go +++ b/ioutils/fileProgess.go @@ -121,10 +121,10 @@ func NewFileProgressPathMode(filepath string, mode int, perm os.FileMode) (FileP } func NewFileProgressPathWrite(filepath string, create, overwrite bool, perm os.FileMode) (FileProgress, errors.Error) { - mode := os.O_RDWR | os.O_EXCL | os.O_TRUNC + mode := os.O_RDWR | os.O_TRUNC if _, err := os.Stat(filepath); err != nil && os.IsNotExist(err) && create { - mode = os.O_RDWR | os.O_EXCL | os.O_CREATE + mode = os.O_RDWR | os.O_CREATE | os.O_TRUNC } else if err != nil { return nil, ErrorIOFileStat.ErrorParent(err) } From 6cae0439ff93afac51c60f5be23741e6c8fad289 Mon Sep 17 00:00:00 2001 From: Nicolas JUHEL Date: Mon, 12 Oct 2020 01:14:20 +0200 Subject: [PATCH 2/3] Fix untar archive + optimize --- archive/tar/reader.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/archive/tar/reader.go b/archive/tar/reader.go index 49aa1878..0bb4674b 100644 --- a/archive/tar/reader.go +++ b/archive/tar/reader.go @@ -148,8 +148,8 @@ func writeContent(r io.Reader, h *tar.Header, out string, defaultDirPerm os.File } func dirIsExistOrCreate(dirname string, dirPerm os.FileMode) errors.Error { - if i, e := os.Stat(path.Dir(dirname)); e != nil && os.IsNotExist(e) { - if e = os.MkdirAll(path.Dir(dirname), dirPerm); e != nil { + if i, e := os.Stat(dirname); e != nil && os.IsNotExist(e) { + if e = os.MkdirAll(dirname, dirPerm); e != nil { return ErrorDirCreate.ErrorParent(e) } } else if e != nil { @@ -162,14 +162,15 @@ func dirIsExistOrCreate(dirname string, dirPerm os.FileMode) errors.Error { } func notDirExistCannotClean(filename string) errors.Error { - if i, e := os.Stat(filename); e != nil && !os.IsNotExist(e) { + if i, e := os.Stat(filename); e != nil && os.IsNotExist(e) { + return nil + } else if e != nil { return ErrorDestinationStat.ErrorParent(e) - } else if e == nil && i.IsDir() { + } else if i.IsDir() { return ErrorDestinationIsDir.Error(nil) - } else if e == nil { - if e = os.Remove(filename); e != nil { - return ErrorDestinationRemove.ErrorParent(e) - } + } else if e = os.Remove(filename); e != nil { + return ErrorDestinationRemove.ErrorParent(e) } + return nil } From 2786d100081080e7c6b1e07cc77e4047de937f79 Mon Sep 17 00:00:00 2001 From: Nicolas JUHEL Date: Mon, 12 Oct 2020 02:17:38 +0200 Subject: [PATCH 3/3] Bump dependancies --- go.mod | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 91ee560d..bef522de 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/json-iterator/go v1.1.10 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect - github.com/mattn/go-colorable v0.1.7 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/olekukonko/tablewriter v0.0.4 @@ -38,14 +38,14 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect github.com/stretchr/testify v1.5.1 // indirect - github.com/ugorji/go v1.1.9 // indirect + github.com/ugorji/go v1.1.10 // indirect github.com/vbauerster/mpb/v5 v5.3.0 github.com/xanzy/go-gitlab v0.38.1 - golang.org/x/crypto v0.0.0-20201002094018-c90954cbb977 - golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 + golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 + golang.org/x/net v0.0.0-20201010224723-4f7140c49acb golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 - golang.org/x/sync v0.0.0-20200930132711-30421366ff76 - golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect + golang.org/x/sync v0.0.0-20201008141435-b3e1573b7520 + golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 // indirect golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect gopkg.in/yaml.v2 v2.3.0 // indirect )