Bug 739555 - Do not use .localPath of an IM server in amUtils.js. r+a=dbienvenu.
authoraceman <acelists@atlas.sk>
Fri, 13 Apr 2012 12:29:37 +0200
changeset 11187 bcbac54d419e075487e680a8cb7f2565ddf289e3
parent 11186 9633d82db33f82c003d8b249abacfd86dac5bbbb
child 11188 0a45ae40a58b48dd32ac390627f295186309e0df
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs739555
Bug 739555 - Do not use .localPath of an IM server in amUtils.js. r+a=dbienvenu.
mailnews/base/prefs/content/amUtils.js
--- a/mailnews/base/prefs/content/amUtils.js
+++ b/mailnews/base/prefs/content/amUtils.js
@@ -54,39 +54,40 @@ function BrowseForLocalFolders()
                   .getAttribute("filepickertitle"),
           nsIFilePicker.modeGetFolder);
 
   var currentFolder = Components.classes[LOCALFILE_CTRID]
                                 .createInstance(nsILocalFile);
   currentFolder.initWithPath(currentFolderTextBox.value);
   fp.displayDirectory = currentFolder;
 
-  if (fp.show() == nsIFilePicker.returnOK)
-  {
-    // Retrieve the selected folder.
-    var selectedFolder = fp.file;
+  if (fp.show() != nsIFilePicker.returnOK)
+    return;
+
+  // Retrieve the selected folder.
+  let selectedFolder = fp.file;
 
-    // check that no other account/server has this same local directory
-    var allServers = MailServices.accounts.allServers;
-    for (var i = allServers.Count(); --i >= 0;)
-    {
-      var currentServer = allServers.QueryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
-      if (currentServer.key != gServer.key &&
-          currentServer.localPath.equals(selectedFolder))
-      {
-        var dirAlreadyUsed = top.document.getElementById("bundle_prefs")
-                                .getFormattedString("directoryUsedByOtherAccount",
-                                                    [currentServer.prettyName]);
-        Services.prompt.alert(window, null, dirAlreadyUsed);
-        return;
-      }
+  // check that no other account/server has this same local directory
+  let allServers = MailServices.accounts.allServers;
+  for (let i = allServers.Count(); --i >= 0;) {
+    let currentServer = allServers
+      .QueryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
+    // IM server type does not have a .localPath
+    if (currentServer.key == gServer.key || currentServer.type == "im")
+      continue;
+
+    if (currentServer.localPath.equals(selectedFolder)) {
+      let dirAlreadyUsed = top.document.getElementById("bundle_prefs")
+                              .getFormattedString("directoryUsedByOtherAccount",
+                                                  [currentServer.prettyName]);
+      Services.prompt.alert(window, null, dirAlreadyUsed);
+      return;
     }
-
-    currentFolderTextBox.value = selectedFolder.path;
   }
+  currentFolderTextBox.value = selectedFolder.path;
 }
 
 function hostnameIsIllegal(hostname)
 {
   // XXX TODO do a complete check.
   // this only checks for illegal characters in the hostname
   // but hostnames like "...." and "_" and ".111" will get by
   // my test.