diff options
author | John Reck <jreck@google.com> | 2010-12-21 14:40:14 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-12-21 17:28:04 -0800 |
commit | 75c720eeaa29a5373bd6ebc414c3d01fa2bb7eed (patch) | |
tree | a4151c9f8f1e8d929ecd7d924623c20ed3c5189c /src | |
parent | 00a05f0d74112440710e61978cc698fc297fb5cb (diff) | |
download | packages_apps_Browser-75c720eeaa29a5373bd6ebc414c3d01fa2bb7eed.zip packages_apps_Browser-75c720eeaa29a5373bd6ebc414c3d01fa2bb7eed.tar.gz packages_apps_Browser-75c720eeaa29a5373bd6ebc414c3d01fa2bb7eed.tar.bz2 |
Delete unused images
Bug: 3303813
When clearing history or deleting a bookmark, the images associated
are never removed. This will prune unused images on every delete or
update.
Change-Id: I733bf4bd9c06cd8e827a576738f7873d6bdaf8bb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/provider/BrowserProvider2.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java index be9db9a..1eaad25 100644 --- a/src/com/android/browser/provider/BrowserProvider2.java +++ b/src/com/android/browser/provider/BrowserProvider2.java @@ -96,6 +96,11 @@ public class BrowserProvider2 extends SQLiteContentProvider { "url LIKE ? OR url LIKE ? OR url LIKE ? OR url LIKE ?" + " OR title LIKE ?"; + private static final String IMAGE_PRUNE = + "url_key NOT IN (SELECT url FROM bookmarks " + + "WHERE url IS NOT NULL AND deleted == 0) AND url_key NOT IN " + + "(SELECT url FROM history WHERE url IS NOT NULL)"; + static final int BOOKMARKS = 1000; static final int BOOKMARKS_ID = 1001; static final int BOOKMARKS_FOLDER = 1002; @@ -936,7 +941,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { // fall through } case BOOKMARKS: { - return deleteBookmarks(selection, selectionArgs, callerIsSyncAdapter); + int deleted = deleteBookmarks(selection, selectionArgs, callerIsSyncAdapter); + pruneImages(); + return deleted; } case HISTORY_ID: { @@ -947,7 +954,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { } case HISTORY: { filterSearchClient(selectionArgs); - return db.delete(TABLE_HISTORY, selection, selectionArgs); + int deleted = db.delete(TABLE_HISTORY, selection, selectionArgs); + pruneImages(); + return deleted; } case SEARCHES_ID: { @@ -1257,8 +1266,10 @@ public class BrowserProvider2 extends SQLiteContentProvider { // fall through } case BOOKMARKS: { - return updateBookmarksInTransaction(values, selection, selectionArgs, + int updated = updateBookmarksInTransaction(values, selection, selectionArgs, callerIsSyncAdapter); + pruneImages(); + return updated; } case HISTORY_ID: { @@ -1268,7 +1279,9 @@ public class BrowserProvider2 extends SQLiteContentProvider { // fall through } case HISTORY: { - return updateHistoryInTransaction(values, selection, selectionArgs); + int updated = updateHistoryInTransaction(values, selection, selectionArgs); + pruneImages(); + return updated; } case SYNCSTATE: { @@ -1462,6 +1475,11 @@ public class BrowserProvider2 extends SQLiteContentProvider { return imageValues; } + void pruneImages() { + final SQLiteDatabase db = mOpenHelper.getWritableDatabase(); + db.delete(TABLE_IMAGES, IMAGE_PRUNE, null); + } + static class SuggestionsCursor extends AbstractCursor { private static final int ID_INDEX = 0; private static final int URL_INDEX = 1; |