diff options
author | Ficus Kirkpatrick <ficus@android.com> | 2013-04-03 17:02:49 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-04-03 17:02:49 +0000 |
commit | ebae4c6f962818ad0389b255009a42b03d3993cd (patch) | |
tree | 8a01b70d193fc0ce2f4aebc6a7bacc413179ddb1 /src | |
parent | 3050b38a767b6adfd08cc9412132d1374bbf6d36 (diff) | |
parent | 445ed3471fb55abae917324375b30c8a677e5d0b (diff) | |
download | volley-ebae4c6f962818ad0389b255009a42b03d3993cd.tar.gz |
Merge "Move directory creation off the main thread."
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/volley/toolbox/DiskBasedCache.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/com/android/volley/toolbox/DiskBasedCache.java b/src/com/android/volley/toolbox/DiskBasedCache.java index c04ba87..75bf4d1 100644 --- a/src/com/android/volley/toolbox/DiskBasedCache.java +++ b/src/com/android/volley/toolbox/DiskBasedCache.java @@ -72,12 +72,6 @@ public class DiskBasedCache implements Cache { public DiskBasedCache(File rootDirectory, int maxCacheSizeInBytes) { mRootDirectory = rootDirectory; mMaxCacheSizeInBytes = maxCacheSizeInBytes; - - if (!mRootDirectory.exists()) { - if (!mRootDirectory.mkdirs()) { - VolleyLog.e("Unable to create cache dir %s", mRootDirectory.getAbsolutePath()); - } - } } /** @@ -140,10 +134,17 @@ public class DiskBasedCache implements Cache { /** * Initializes the DiskBasedCache by scanning for all files currently in the - * specified root directory. + * specified root directory. Creates the root directory if necessary. */ @Override public synchronized void initialize() { + if (!mRootDirectory.exists()) { + if (!mRootDirectory.mkdirs()) { + VolleyLog.e("Unable to create cache dir %s", mRootDirectory.getAbsolutePath()); + } + return; + } + File[] files = mRootDirectory.listFiles(); if (files == null) { return; |