Merge pull request #389 from peter-evans/fix-symlink-extraction
Fix symlink extraction
This commit is contained in:
commit
f4612404c4
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Tests extraction of symlink, hardlink and regular files to a path that is a non-empty directory
|
||||||
|
FROM gcr.io/kaniko-test/extraction-base-image:latest
|
||||||
|
|
@ -193,7 +193,7 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error {
|
||||||
// Check if something already exists at path (symlinks etc.)
|
// Check if something already exists at path (symlinks etc.)
|
||||||
// If so, delete it
|
// If so, delete it
|
||||||
if FilepathExists(path) {
|
if FilepathExists(path) {
|
||||||
if err := os.Remove(path); err != nil {
|
if err := os.RemoveAll(path); err != nil {
|
||||||
return errors.Wrapf(err, "error removing %s to make way for new file.", path)
|
return errors.Wrapf(err, "error removing %s to make way for new file.", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +242,7 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error {
|
||||||
// Check if something already exists at path
|
// Check if something already exists at path
|
||||||
// If so, delete it
|
// If so, delete it
|
||||||
if FilepathExists(path) {
|
if FilepathExists(path) {
|
||||||
if err := os.Remove(path); err != nil {
|
if err := os.RemoveAll(path); err != nil {
|
||||||
return errors.Wrapf(err, "error removing %s to make way for new link", hdr.Name)
|
return errors.Wrapf(err, "error removing %s to make way for new link", hdr.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +260,7 @@ func extractFile(dest string, hdr *tar.Header, tr io.Reader) error {
|
||||||
// Check if something already exists at path
|
// Check if something already exists at path
|
||||||
// If so, delete it
|
// If so, delete it
|
||||||
if FilepathExists(path) {
|
if FilepathExists(path) {
|
||||||
if err := os.Remove(path); err != nil {
|
if err := os.RemoveAll(path); err != nil {
|
||||||
return errors.Wrapf(err, "error removing %s to make way for new symlink", hdr.Name)
|
return errors.Wrapf(err, "error removing %s to make way for new symlink", hdr.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue