Bug 1530615: Don't show a missing profile as in use in about:profiles. r=Gijs
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 05 Mar 2019 11:35:33 +0000
changeset 520261 c76f213ca5bd
parent 520260 2ff1c636903d
child 520262 2ee118b40f31
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1530615
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530615: Don't show a missing profile as in use in about:profiles. r=Gijs This is about the simplest fix possible. Anything else would require strings so I want to wait on UX before implementing that. This simply don't consider a profile locked if the directory doesn't exist and doesn't show options to open the directories if they don't exist. Differential Revision: https://phabricator.services.mozilla.com/D22030
toolkit/content/aboutProfiles.js
--- a/toolkit/content/aboutProfiles.js
+++ b/toolkit/content/aboutProfiles.js
@@ -30,17 +30,20 @@ function refreshUI() {
   for (let profile of ProfileService.profiles) {
     let isCurrentProfile = profile == currentProfile;
     let isInUse = isCurrentProfile;
     if (!isInUse) {
       try {
         let lock = profile.lock({});
         lock.unlock();
       } catch (e) {
-        isInUse = true;
+        if (e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
+            e.result != Cr.NS_ERROR_FILE_NOT_DIRECTORY) {
+          isInUse = true;
+        }
       }
     }
     display({
       profile,
       isDefault: profile == defaultProfile,
       isCurrentProfile,
       isInUse,
     });
@@ -55,22 +58,16 @@ function refreshUI() {
   } else {
     restartSafeModeButton.setAttribute("disabled", "true");
   }
 
   let restartNormalModeButton = document.getElementById("restart-button");
   restartNormalModeButton.onclick = function() { restart(false); };
 }
 
-function openDirectory(dir) {
-  let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
-                                           "nsIFile", "initWithPath");
-  new nsLocalFile(dir).reveal();
-}
-
 function display(profileData) {
   let parent = document.getElementById("profiles");
 
   let div = document.createElement("div");
   parent.appendChild(div);
 
   let name = document.createElement("h2");
 
@@ -102,38 +99,41 @@ function display(profileData) {
     th.setAttribute("class", "column");
     document.l10n.setAttributes(th, title);
     tr.appendChild(th);
 
     let td = document.createElement("td");
     tr.appendChild(td);
 
     if (dir) {
-      td.appendChild(document.createTextNode(value));
-      let button = document.createElement("button");
-      button.setAttribute("class", "opendir");
-      document.l10n.setAttributes(button, "profiles-opendir");
+      td.appendChild(document.createTextNode(value.path));
+
+      if (value.exists()) {
+        let button = document.createElement("button");
+        button.setAttribute("class", "opendir");
+        document.l10n.setAttributes(button, "profiles-opendir");
 
-      td.appendChild(button);
+        td.appendChild(button);
 
-      button.addEventListener("click", function(e) {
-        openDirectory(value);
-      });
+        button.addEventListener("click", function(e) {
+          value.reveal();
+        });
+      }
     } else {
       document.l10n.setAttributes(td, value);
     }
   }
 
   createItem("profiles-is-default",
     profileData.isDefault ? "profiles-yes" : "profiles-no");
 
-  createItem("profiles-rootdir", profileData.profile.rootDir.path, true);
+  createItem("profiles-rootdir", profileData.profile.rootDir, true);
 
   if (profileData.profile.localDir.path != profileData.profile.rootDir.path) {
-    createItem("profiles-localdir", profileData.profile.localDir.path, true);
+    createItem("profiles-localdir", profileData.profile.localDir, true);
   }
 
   let renameButton = document.createElement("button");
   document.l10n.setAttributes(renameButton, "profiles-rename");
   renameButton.onclick = function() {
     renameProfile(profileData.profile);
   };
   div.appendChild(renameButton);