summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d/common
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2012-05-09 10:38:11 +0800
committerHung-ying Tyan <tyanh@google.com>2012-05-09 10:46:51 +0800
commit6ba7a26bbb0b53eaced67714a6652ebdec74ac4a (patch)
tree3856b77cba734638fa92fb8519a35b057f102389 /gallerycommon/src/com/android/gallery3d/common
parentac02f46aa7ec727b839affb9aee415f01c1c2193 (diff)
downloadandroid_packages_apps_Snap-6ba7a26bbb0b53eaced67714a6652ebdec74ac4a.tar.gz
android_packages_apps_Snap-6ba7a26bbb0b53eaced67714a6652ebdec74ac4a.tar.bz2
android_packages_apps_Snap-6ba7a26bbb0b53eaced67714a6652ebdec74ac4a.zip
Mark FileCache initialized after init really goes through.
Bug: 5988196 Change-Id: Ia826ce6a33c200a2cd09c21d7ef22f4dd161caa9
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) {