diff options
author | Vasu Nori <vnori@google.com> | 2010-12-19 20:31:00 -0800 |
---|---|---|
committer | Vasu Nori <vnori@google.com> | 2010-12-19 20:33:54 -0800 |
commit | 6916b03e022b7ae391a1ed66a857db6e80b04c65 (patch) | |
tree | 33373d6f1bef3d28fab96ec0fa8503eb86d57a09 /core/java/android/app | |
parent | 4c7cc34127efa3308e1a09b28728868911b79789 (diff) | |
download | frameworks_base-6916b03e022b7ae391a1ed66a857db6e80b04c65.zip frameworks_base-6916b03e022b7ae391a1ed66a857db6e80b04c65.tar.gz frameworks_base-6916b03e022b7ae391a1ed66a857db6e80b04c65.tar.bz2 |
if a download dir doesn't exist, create it or fail fast
in HC, using DownloadManager public API, download directories
named by the constants Environment.DOWNLOAD_*
may ot exist. theyneed to be created or
the download request should fail ASAP.
bug:3297328
Change-Id: Ic87023d8fe98bd240744f66607a5400b7825e17e
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/DownloadManager.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java index a24375e..12f4a18 100644 --- a/core/java/android/app/DownloadManager.java +++ b/core/java/android/app/DownloadManager.java @@ -453,7 +453,19 @@ public class DownloadManager { * @return this object */ public Request setDestinationInExternalPublicDir(String dirType, String subPath) { - setDestinationFromBase(Environment.getExternalStoragePublicDirectory(dirType), subPath); + File file = Environment.getExternalStoragePublicDirectory(dirType); + if (file.exists()) { + if (!file.isDirectory()) { + throw new IllegalStateException(file.getAbsolutePath() + + " already exists and is not a directory"); + } + } else { + if (!file.mkdir()) { + throw new IllegalStateException("Unable to create directory: "+ + file.getAbsolutePath()); + } + } + setDestinationFromBase(file, subPath); return this; } |