summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d/common
diff options
context:
space:
mode:
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d/common')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/FileCache.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/FileCache.java b/gallerycommon/src/com/android/gallery3d/common/FileCache.java
index 938ef8c1a..a69487f4c 100644
--- a/gallerycommon/src/com/android/gallery3d/common/FileCache.java
+++ b/gallerycommon/src/com/android/gallery3d/common/FileCache.java
@@ -191,7 +191,6 @@ public class FileCache implements Closeable {
private synchronized void initialize() {
if (mInitialized) return;
- mInitialized = true;
if (!mRootDir.isDirectory()) {
mRootDir.mkdirs();
@@ -209,6 +208,10 @@ public class FileCache implements Closeable {
cursor.close();
}
if (mTotalBytes > mCapacity) freeSomeSpaceIfNeed(MAX_DELETE_COUNT);
+
+ // Mark initialized when everything above went through. If an exception was thrown,
+ // initialize() will be retried later.
+ mInitialized = true;
}
private void freeSomeSpaceIfNeed(int maxDeleteFileCount) {