From 694bd997cb7fe64379fb02e9cc090ae9833697c1 Mon Sep 17 00:00:00 2001 From: eguven Date: Thu, 9 Nov 2017 07:14:21 -0800 Subject: [PATCH] Re-enable index file store at the end of the SimpleCache.initialize() In the case converting cache files from an earlier version of SimpleCache, there is no previous version of the index file. If the app doesn't call any SimpleCache methods which would make the index file stored before it exists whole data gets lost. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175153650 --- .../android/exoplayer2/upstream/cache/SimpleCache.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java index 9739f21923..599474d6c3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCache.java @@ -16,6 +16,7 @@ package com.google.android.exoplayer2.upstream.cache; import android.os.ConditionVariable; +import android.util.Log; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.Assertions; import java.io.File; @@ -31,6 +32,8 @@ import java.util.TreeSet; */ public final class SimpleCache implements Cache { + private static final String TAG = "SimpleCache"; + private final File cacheDir; private final CacheEvictor evictor; private final HashMap lockedSpans; @@ -288,7 +291,11 @@ public final class SimpleCache implements Cache { } index.removeEmpty(); - // Don't call index.store() here so initialization doesn't fail because of write issues. + try { + index.store(); + } catch (CacheException e) { + Log.e(TAG, "Storing index file failed", e); + } } /**