Merge "Fix crash in ConfigUpdater when the target dir doesn't exist." into jb-mr2-dev
diff --git a/services/java/com/android/server/updates/ConfigUpdateInstallReceiver.java b/services/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
index d603cfa..c94f7c1 100644
--- a/services/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
+++ b/services/java/com/android/server/updates/ConfigUpdateInstallReceiver.java
@@ -226,8 +226,6 @@
         FileOutputStream out = null;
         File tmp = null;
         try {
-            // create the temporary file
-            tmp = File.createTempFile("journal", "", dir);
             // create the parents for the destination file
             File parent = file.getParentFile();
             parent.mkdirs();
@@ -235,6 +233,8 @@
             if (!parent.exists()) {
                 throw new IOException("Failed to create directory " + parent.getCanonicalPath());
             }
+            // create the temporary file
+            tmp = File.createTempFile("journal", "", dir);
             // mark tmp -rw-r--r--
             tmp.setReadable(true, false);
             // write to it