TBR: jiri/profiles: Fix unzip utility.
Some zip files seem to include files before their parent directory, so
we must create any parent directories before unzipping files.
PresubmitTest: none
Change-Id: Id44c512940d5689da7bebc5c9581c014bc486828
diff --git a/profiles/util.go b/profiles/util.go
index 248fdba..61717f4 100644
--- a/profiles/util.go
+++ b/profiles/util.go
@@ -324,6 +324,13 @@
if zFile.FileInfo().IsDir() {
return ctx.Run().MkdirAll(fileDst, zFile.Mode())
}
+
+ // Make sure the parent directory exists. Note that sometimes files
+ // can appear in a zip file before their directory.
+ if err := ctx.Run().MkdirAll(filepath.Dir(fileDst), zFile.Mode()); err != nil {
+ return err
+ }
+
file, err := ctx.Run().OpenFile(fileDst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, zFile.Mode())
if err != nil {
return err