Fix #647 Copy dir permissions
* update otiai10 to latest version which has correct permission logic
This commit is contained in:
parent
48f66e958c
commit
e2d1cbfe71
3
go.mod
3
go.mod
|
|
@ -71,8 +71,7 @@ require (
|
||||||
github.com/opencontainers/runtime-spec v1.0.1 // indirect
|
github.com/opencontainers/runtime-spec v1.0.1 // indirect
|
||||||
github.com/opencontainers/selinux v1.0.0-rc1 // indirect
|
github.com/opencontainers/selinux v1.0.0-rc1 // indirect
|
||||||
github.com/opentracing/opentracing-go v1.0.2 // indirect
|
github.com/opentracing/opentracing-go v1.0.2 // indirect
|
||||||
github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1
|
github.com/otiai10/copy v1.0.2
|
||||||
github.com/otiai10/mint v1.3.0 // indirect
|
|
||||||
github.com/pborman/uuid v1.2.0 // indirect
|
github.com/pborman/uuid v1.2.0 // indirect
|
||||||
github.com/pelletier/go-buffruneio v0.2.0 // indirect
|
github.com/pelletier/go-buffruneio v0.2.0 // indirect
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||||
|
|
|
||||||
2
go.sum
2
go.sum
|
|
@ -176,6 +176,8 @@ github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg
|
||||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||||
github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1 h1:A7kMXwDPBTfIVRv2l6XV3U6Su3SzLUzZjxnDDQVZDIY=
|
github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1 h1:A7kMXwDPBTfIVRv2l6XV3U6Su3SzLUzZjxnDDQVZDIY=
|
||||||
github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1/go.mod h1:pXzZSDlN+HPzSdyIBnKNN9ptD9Hx7iZMWIJPTwo4FPE=
|
github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1/go.mod h1:pXzZSDlN+HPzSdyIBnKNN9ptD9Hx7iZMWIJPTwo4FPE=
|
||||||
|
github.com/otiai10/copy v1.0.2 h1:DDNipYy6RkIkjMwy+AWzgKiNTyj2RUI9yEMeETEpVyc=
|
||||||
|
github.com/otiai10/copy v1.0.2/go.mod h1:c7RpqBkwMom4bYTSkLSym4VSJz/XtncWRAj/J4PEIMY=
|
||||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95 h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs=
|
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95 h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs=
|
||||||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
||||||
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
|
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
testdata.copy
|
testdata.copy
|
||||||
coverage.txt
|
coverage.txt
|
||||||
|
vendor
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// tmpPermissionForDirectory makes the destination directory writable,
|
||||||
|
// so that stuff can be copied recursively even if any original directory is NOT writable.
|
||||||
|
// See https://github.com/otiai10/copy/pull/9 for more information.
|
||||||
|
tmpPermissionForDirectory = os.FileMode(0755)
|
||||||
|
)
|
||||||
|
|
||||||
// Copy copies src to dest, doesn't matter if src is a directory or a file
|
// Copy copies src to dest, doesn't matter if src is a directory or a file
|
||||||
func Copy(src, dest string) error {
|
func Copy(src, dest string) error {
|
||||||
info, err := os.Lstat(src)
|
info, err := os.Lstat(src)
|
||||||
|
|
@ -63,9 +70,14 @@ func fcopy(src, dest string, info os.FileInfo) error {
|
||||||
// and pass everything to "copy" recursively.
|
// and pass everything to "copy" recursively.
|
||||||
func dcopy(srcdir, destdir string, info os.FileInfo) error {
|
func dcopy(srcdir, destdir string, info os.FileInfo) error {
|
||||||
|
|
||||||
if err := os.MkdirAll(destdir, info.Mode()); err != nil {
|
originalMode := info.Mode()
|
||||||
|
|
||||||
|
// Make dest dir with 0755 so that everything writable.
|
||||||
|
if err := os.MkdirAll(destdir, tmpPermissionForDirectory); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Recover dir mode with original one.
|
||||||
|
defer os.Chmod(destdir, originalMode)
|
||||||
|
|
||||||
contents, err := ioutil.ReadDir(srcdir)
|
contents, err := ioutil.ReadDir(srcdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -79,6 +91,7 @@ func dcopy(srcdir, destdir string, info os.FileInfo) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
module github.com/otiai10/copy
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require github.com/otiai10/mint v1.3.0
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
|
||||||
|
github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
|
||||||
|
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
|
||||||
|
|
@ -331,7 +331,7 @@ github.com/opencontainers/selinux/go-selinux/label
|
||||||
github.com/opentracing/opentracing-go
|
github.com/opentracing/opentracing-go
|
||||||
github.com/opentracing/opentracing-go/ext
|
github.com/opentracing/opentracing-go/ext
|
||||||
github.com/opentracing/opentracing-go/log
|
github.com/opentracing/opentracing-go/log
|
||||||
# github.com/otiai10/copy v0.0.0-20180813032824-7e9a647135a1
|
# github.com/otiai10/copy v1.0.2
|
||||||
github.com/otiai10/copy
|
github.com/otiai10/copy
|
||||||
# github.com/pelletier/go-buffruneio v0.2.0
|
# github.com/pelletier/go-buffruneio v0.2.0
|
||||||
github.com/pelletier/go-buffruneio
|
github.com/pelletier/go-buffruneio
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue