mirror of
https://github.com/androidx/media.git
synced 2025-05-10 00:59:51 +08:00
Fix unnecessary rewrite of cache index file after CachedContentIndex.readFile()
Prevented readFile() setting "changed" boolean to true every time. It's set only if encryption key is set but the index file isn't encrypted. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140714173
This commit is contained in:
parent
836cefcdd6
commit
f3dbb74613
@ -235,13 +235,17 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
input = new DataInputStream(new CipherInputStream(inputStream, cipher));
|
input = new DataInputStream(new CipherInputStream(inputStream, cipher));
|
||||||
|
} else {
|
||||||
|
if (cipher != null) {
|
||||||
|
changed = true; // Force index to be rewritten encrypted after read.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = input.readInt();
|
int count = input.readInt();
|
||||||
int hashCode = 0;
|
int hashCode = 0;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
CachedContent cachedContent = new CachedContent(input);
|
CachedContent cachedContent = new CachedContent(input);
|
||||||
addNew(cachedContent);
|
add(cachedContent);
|
||||||
hashCode += cachedContent.headerHashCode();
|
hashCode += cachedContent.headerHashCode();
|
||||||
}
|
}
|
||||||
if (input.readInt() != hashCode) {
|
if (input.readInt() != hashCode) {
|
||||||
@ -302,10 +306,14 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds the given CachedContent to the index. */
|
private void add(CachedContent cachedContent) {
|
||||||
/*package*/ void addNew(CachedContent cachedContent) {
|
|
||||||
keyToContent.put(cachedContent.key, cachedContent);
|
keyToContent.put(cachedContent.key, cachedContent);
|
||||||
idToKey.put(cachedContent.id, cachedContent.key);
|
idToKey.put(cachedContent.id, cachedContent.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds the given CachedContent to the index. */
|
||||||
|
/*package*/ void addNew(CachedContent cachedContent) {
|
||||||
|
add(cachedContent);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user