ApplyLayer() use RemoveAll to handle removing directories

rmTargetPath can be a directory, so we have to use RemoveAll() or we
will fail to whiteout non-empty directories.
Upstream-commit: 006e2a600ce689770ba2c49805bc4f634976f365
Component: engine
This commit is contained in:
Alexander Larsson
2013-11-14 22:56:18 +01:00
parent 5f7a312280
commit 39e4a0bc9e

View File

@ -49,7 +49,7 @@ func ApplyLayer(dest string, layer Archive) error {
rmTargetPath := filepath.Join(filepath.Dir(fullPath), rmTargetName)
// Remove the file targeted by the whiteout
log.Printf("Removing whiteout target %s", rmTargetPath)
_ = os.Remove(rmTargetPath)
_ = os.RemoveAll(rmTargetPath)
// Remove the whiteout itself
log.Printf("Removing whiteout %s", fullPath)
_ = os.RemoveAll(fullPath)