Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from oracle/fix-layer-overwrite
Browse files Browse the repository at this point in the history
Remove files from lower layer before writing
  • Loading branch information
vishvananda authored Jul 20, 2017
2 parents b910e73 + d4226a0 commit 2d03f5f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ func extractLayer(layer *Layer, outDir string) error {
}

path := filepath.Join(outDir, clean)
info, err := os.Lstat(path)
// remove any existing file at the location unless both locations are a dir
if err == nil && !(hdr.Typeflag == tar.TypeDir && info.IsDir()) {
if err := os.RemoveAll(path); err != nil {
logrus.Warnf("Failed to remove %s", path)
}
}
switch hdr.Typeflag {
case tar.TypeDir:
os.MkdirAll(path, 0755)
Expand Down

0 comments on commit 2d03f5f

Please sign in to comment.