summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2012-10-11 10:35:01 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-11 10:35:01 -0700
commit1ac23d436d226a926adc5685b8cf30a32a0afea7 (patch)
tree411c1095c6bff47494679b6eefc3ea1bc770e8d4 /gallerycommon/src/com
parent44ee4e0a23c2b15c9377b190e27a8243c221a921 (diff)
parentc33eee56b585929499dd34435f07257db4f5c245 (diff)
downloadandroid_packages_apps_Snap-1ac23d436d226a926adc5685b8cf30a32a0afea7.zip
android_packages_apps_Snap-1ac23d436d226a926adc5685b8cf30a32a0afea7.tar.gz
android_packages_apps_Snap-1ac23d436d226a926adc5685b8cf30a32a0afea7.tar.bz2
Merge "Clear cached stitching preview thumbnails." into gb-ub-photos-arches
Diffstat (limited to 'gallerycommon/src/com')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/BlobCache.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/BlobCache.java b/gallerycommon/src/com/android/gallery3d/common/BlobCache.java
index 7788e61..3c131e5 100644
--- a/gallerycommon/src/com/android/gallery3d/common/BlobCache.java
+++ b/gallerycommon/src/com/android/gallery3d/common/BlobCache.java
@@ -74,6 +74,7 @@ import java.io.RandomAccessFile;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
+import java.util.Arrays;
import java.util.zip.Adler32;
public class BlobCache implements Closeable {
@@ -379,6 +380,16 @@ public class BlobCache implements Closeable {
updateIndexHeader();
}
+ public void clearEntry(long key) throws IOException {
+ if (!lookupInternal(key, mActiveHashStart)) {
+ return; // Nothing to clear
+ }
+ byte[] header = mBlobHeader;
+ Arrays.fill(header, (byte) 0);
+ mActiveDataFile.seek(mFileOffset);
+ mActiveDataFile.write(header);
+ }
+
// Appends the data to the active file. It also updates the hash entry.
// The proper hash entry (suitable for insertion or replacement) must be
// pointed by mSlotOffset.
@@ -485,6 +496,9 @@ public class BlobCache implements Closeable {
return false;
}
long blobKey = readLong(header, BH_KEY);
+ if (blobKey == 0) {
+ return false; // This entry has been cleared.
+ }
if (blobKey != req.key) {
Log.w(TAG, "blob key does not match: " + blobKey);
return false;