Browse Source

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.
Alexander Larsson 11 years ago
parent
commit
006e2a600c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      archive/diff.go

+ 1 - 1
archive/diff.go

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