Bug 716729 - Consider deleted entries when looking whether to insert or update. r=lucasr
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Mon, 26 Mar 2012 19:06:51 +0200
changeset 90669 7573b4f06d486c02e25df55db48b6b8744ca81b3
parent 90668 2940c6c8ef6620583789b4752c96cb068d3891d8
child 90670 c730b2ecebecc36d3917e14c1e128574299a2208
push id1069
push usermfinkle@mozilla.com
push dateWed, 04 Apr 2012 14:22:33 +0000
treeherdermozilla-aurora@883536e3b5da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs716729
milestone13.0a2
Bug 716729 - Consider deleted entries when looking whether to insert or update. r=lucasr
mobile/android/base/ProfileMigrator.java
--- a/mobile/android/base/ProfileMigrator.java
+++ b/mobile/android/base/ProfileMigrator.java
@@ -187,25 +187,32 @@ public class ProfileMigrator {
         new PlacesRunnable().run();
     }
 
     private class PlacesRunnable implements Runnable {
         private Map<Long, Long> mRerootMap;
         private ArrayList<ContentProviderOperation> mOperations;
 
         protected Uri getBookmarksUri() {
-            return Bookmarks.CONTENT_URI;
+            Uri.Builder uriBuilder = Bookmarks.CONTENT_URI.buildUpon()
+                .appendQueryParameter(BrowserContract.PARAM_SHOW_DELETED, "1");
+            return uriBuilder.build();
         }
 
         protected Uri getHistoryUri() {
-            return History.CONTENT_URI;
+            Uri.Builder uriBuilder = History.CONTENT_URI.buildUpon()
+                .appendQueryParameter(BrowserContract.PARAM_SHOW_DELETED, "1");
+            return uriBuilder.build();
+
         }
 
         protected Uri getImagesUri() {
-            return Images.CONTENT_URI;
+            Uri.Builder uriBuilder = Images.CONTENT_URI.buildUpon()
+                .appendQueryParameter(BrowserContract.PARAM_SHOW_DELETED, "1");
+            return uriBuilder.build();
         }
 
         private long getFolderId(String guid) {
             Cursor c = null;
 
             try {
                 c = mCr.query(getBookmarksUri(),
                               new String[] { Bookmarks._ID },
@@ -311,16 +318,18 @@ public class ProfileMigrator {
                                    projection,
                                    History.URL + " = ?",
                                    new String[] { url },
                                    null);
 
                 ContentValues values = new ContentValues();
                 ContentProviderOperation.Builder builder = null;
                 values.put(History.DATE_LAST_VISITED, date);
+                // Restore deleted record if possible
+                values.put(History.IS_DELETED, 0);
 
                 if (cursor.moveToFirst()) {
                     int visitsCol = cursor.getColumnIndexOrThrow(History.VISITS);
                     int oldVisits = cursor.getInt(visitsCol);
 
                     values.put(History.VISITS, oldVisits + visits);
                     if (title != null) {
                         values.put(History.TITLE, title);