diff options
Diffstat (limited to 'src/com/android/providers/downloads/Helpers.java')
-rw-r--r-- | src/com/android/providers/downloads/Helpers.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java index 013faf27..3562dac7 100644 --- a/src/com/android/providers/downloads/Helpers.java +++ b/src/com/android/providers/downloads/Helpers.java @@ -141,7 +141,15 @@ public class Helpers { // Claim this filename inside lock to prevent other threads from // clobbering us. We're not paranoid enough to use O_EXCL. try { - new File(path).createNewFile(); + File file = new File(path); + File parent = file.getParentFile(); + + // Make sure the parent directories exists before generates new file + if (parent != null && !parent.exists()) { + parent.mkdirs(); + } + + file.createNewFile(); } catch (IOException e) { throw new StopRequestException(Downloads.Impl.STATUS_FILE_ERROR, "Failed to create target file " + path, e); |