Commit 694bd997 by eguven Committed by Oliver Woodman

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
parent 04baa423
......@@ -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);
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment