summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeremy Condra <gcondra@google.com>2012-09-11 01:11:02 -0700
committerGeremy Condra <gcondra@google.com>2012-09-12 17:53:59 -0700
commit755b87742319a9ff689df08cea0137732a8f0b2d (patch)
treeae09bd22ed0ab18f0526f6111b4cf9417f0d2ffb
parentb631084613e12e1c6a0ae2ad9446e1284b650ccb (diff)
downloadframeworks_base-755b87742319a9ff689df08cea0137732a8f0b2d.zip
frameworks_base-755b87742319a9ff689df08cea0137732a8f0b2d.tar.gz
frameworks_base-755b87742319a9ff689df08cea0137732a8f0b2d.tar.bz2
DO NOT MERGE Create intermediate directories when installing config data.
This prevents an issue where a user factory data resets and hoses the default directory layout- it will now be recreated on first update. Change-Id: I7e3cb47a0fa3aa941a74d46fba7e15865484b66d
-rw-r--r--services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java b/services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java
index ca265f2..35724a3 100644
--- a/services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java
+++ b/services/java/com/android/server/updatable/ConfigUpdateInstallReceiver.java
@@ -218,15 +218,24 @@ public class ConfigUpdateInstallReceiver extends BroadcastReceiver {
try {
// create the temporary file
tmp = File.createTempFile("journal", "", dir);
+ // create the parents for the destination file
+ File parent = file.getParentFile();
+ parent.mkdirs();
+ // check that they were created correctly
+ if (!parent.exists()) {
+ throw new IOException("Failed to create directory " + parent.getCanonicalPath());
+ }
// mark tmp -rw-r--r--
tmp.setReadable(true, false);
// write to it
out = new FileOutputStream(tmp);
out.write(content.getBytes());
// sync to disk
- FileUtils.sync(out);
+ out.getFD().sync();
// atomic rename
- tmp.renameTo(file);
+ if (!tmp.renameTo(file)) {
+ throw new IOException("Failed to atomically rename " + file.getCanonicalPath());
+ }
} catch (IOException e) {
Slog.e(TAG, "Failed to write update", e);
} finally {