diff options
author | Ben Lin <linben@google.com> | 2017-03-30 16:28:27 -0700 |
---|---|---|
committer | Ben Lin <linben@google.com> | 2017-03-31 17:47:29 -0700 |
commit | f4fbacfcaca94b002639f7ed8418c9e001d8703a (patch) | |
tree | 0ce476cb2278eaa8d2a45c9437527dda9b743a9f /src/com | |
parent | 87e10dc58d88ec48a5f07bca1b1eab59f8e37bf4 (diff) | |
download | android_packages_providers_DownloadProvider-f4fbacfcaca94b002639f7ed8418c9e001d8703a.tar.gz android_packages_providers_DownloadProvider-f4fbacfcaca94b002639f7ed8418c9e001d8703a.tar.bz2 android_packages_providers_DownloadProvider-f4fbacfcaca94b002639f7ed8418c9e001d8703a.zip |
Check for Downloads dir's existence and create it if it doesn't exist.
It's possible that Downloads directory (for whatever reason) is not
available on disk, and thus all sorts of bugs happen (Can't create
folder/files, can't query files inside the folder). This will make sure
if DownloadStorageProvider#queryRoot is called, then we
will create the folder.
Test: Builds.
Bug: 35930004
Change-Id: I517ac20c1865f356912decd92a591a37d52ba90b
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/providers/downloads/DownloadStorageProvider.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java index ee963623..08a3f673 100644 --- a/src/com/android/providers/downloads/DownloadStorageProvider.java +++ b/src/com/android/providers/downloads/DownloadStorageProvider.java @@ -113,6 +113,11 @@ public class DownloadStorageProvider extends FileSystemProvider { @Override public Cursor queryRoots(String[] projection) throws FileNotFoundException { + // It's possible that the folder does not exist on disk, so we will create the folder if + // that is the case. If user decides to delete the folder later, then it's OK to fail on + // subsequent queries. + getDownloadsDirectory().mkdirs(); + final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection)); final RowBuilder row = result.newRow(); row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT); @@ -431,8 +436,6 @@ public class DownloadStorageProvider extends FileSystemProvider { Document.FLAG_DIR_PREFERS_LAST_MODIFIED | Document.FLAG_DIR_SUPPORTS_CREATE); } - - /** * Adds the entry from the cursor to the result only if the entry is valid. That is, * if the file exists in the file system. |