summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-04-03 03:08:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-04-03 03:08:59 +0000
commit539dbc52c2de185128485c2dddca4f62a230e525 (patch)
tree7463f2dc820c3ee85269f266d8df09b70cfc8d1c
parentb1502a80460cdc637a783bb8cd34c7f66dc9a075 (diff)
parentf4fbacfcaca94b002639f7ed8418c9e001d8703a (diff)
downloadandroid_packages_providers_DownloadProvider-539dbc52c2de185128485c2dddca4f62a230e525.tar.gz
android_packages_providers_DownloadProvider-539dbc52c2de185128485c2dddca4f62a230e525.tar.bz2
android_packages_providers_DownloadProvider-539dbc52c2de185128485c2dddca4f62a230e525.zip
Merge "Check for Downloads dir's existence and create it if it doesn't exist." into oc-dev
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java7
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.