Bug 1617799 - Migrate value marking the OS X address book as deleted. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 02 Mar 2020 14:44:47 +1300
changeset 37462 ec89a721f9f9f4d7b2c9a1491364bcbd371ff512
parent 37461 46b1f5963bc766e3ce036c5a17374fa94039db25
child 37463 9fb3a451d117e77675c60d6f2b1342d5c7789eed
push id2566
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:20:31 +0000
treeherdercomm-beta@a352facfa0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1617799
Bug 1617799 - Migrate value marking the OS X address book as deleted. r=mkmelin
mailnews/addrbook/jsaddrbook/AddrBookManager.jsm
--- a/mailnews/addrbook/jsaddrbook/AddrBookManager.jsm
+++ b/mailnews/addrbook/jsaddrbook/AddrBookManager.jsm
@@ -114,16 +114,23 @@ function ensureInitialized() {
         let fileName = Services.prefs.getStringPref(`${prefName}.filename`, "");
         let uri = Services.prefs.getStringPref(`${prefName}.uri`, "");
 
         switch (dirType) {
           case MAPI_DIRECTORY_TYPE:
             if (env.exists("MOZ_AUTOMATION")) {
               break;
             }
+            if (Services.prefs.getIntPref(`${prefName}.position`, 1) < 1) {
+              // Migration: the previous address book manager set the position
+              // value to 0 to indicate the removal of an address book.
+              Services.prefs.clearUserPref(`${prefName}.position`);
+              Services.prefs.setIntPref(pref, -1);
+              break;
+            }
             if (AppConstants.platform == "macosx") {
               createDirectoryObject(uri, true);
             } else if (AppConstants.platform == "win") {
               let outlookInterface = Cc[
                 "@mozilla.org/addressbook/outlookinterface;1"
               ].getService(Ci.nsIAbOutlookInterface);
               for (let folderURI of outlookInterface.getFolderURIs(uri)) {
                 let dir = createDirectoryObject(folderURI, true);