Skip to content

Commit

Permalink
Merge pull request #68 from nabbar/fix_file_progress
Browse files Browse the repository at this point in the history
Fix file progress & archive tar
  • Loading branch information
Nicolas JUHEL authored Oct 12, 2020
2 parents df92899 + 2786d10 commit 8d02293
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
17 changes: 9 additions & 8 deletions archive/tar/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
4 changes: 2 additions & 2 deletions ioutils/fileProgess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 8d02293

Please sign in to comment.