From 6ba7a26bbb0b53eaced67714a6652ebdec74ac4a Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Wed, 9 May 2012 10:38:11 +0800 Subject: Mark FileCache initialized after init really goes through. Bug: 5988196 Change-Id: Ia826ce6a33c200a2cd09c21d7ef22f4dd161caa9 --- gallerycommon/src/com/android/gallery3d/common/FileCache.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gallerycommon/src/com/android/gallery3d/common') 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) { -- cgit v1.2.3