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
This commit is contained in:
eguven 2017-11-09 07:14:21 -08:00 committed by Oliver Woodman
parent 04baa42349
commit 694bd997cb

View File

@ -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<String, CacheSpan> 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);
}
}
/**