Bug 1530615: Remove missing profiles from the profile service when showing the profile manager or about:profiles. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D22146

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2019-03-07 18:22:29 +00:00
Родитель d2e43c76a3
Коммит c1a0af0769
2 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -331,5 +331,26 @@ function restart(safeMode) {
}
window.addEventListener("DOMContentLoaded", function() {
// Check if any profiles are missing on the disk and if so remove them.
// We cannot remove profiles while iterating the list returned from the
// profile service, so convert it to a new array first.
try {
let changed = false;
for (let profile of [...ProfileService.profiles]) {
if (!profile.rootDir.exists() || !profile.rootDir.isDirectory()) {
profile.remove(false);
changed = true;
}
}
if (changed) {
ProfileService.flush();
}
} catch (e) {
// There shouldn't be any failures to catch here, but just in case let the
// UI build itself properly.
Cu.reportError(e);
}
refreshUI();
}, {once: true});

Просмотреть файл

@ -24,6 +24,23 @@ function startup() {
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
// Check if any profiles are missing on the disk and if so remove them.
// We cannot remove profiles while iterating the list returned from the
// profile service, so convert it to a new array first.
try {
for (let profile of [...gProfileService.profiles]) {
if (!profile.rootDir.exists() || !profile.rootDir.isDirectory()) {
profile.remove(false);
}
}
// The profile service is always flushed after this dialog completes.
} catch (e) {
// There shouldn't be any failures to catch here, but just in case let the
// UI build itself properly.
Cu.reportError(e);
}
gProfileManagerBundle = document.getElementById("bundle_profileManager");
gBrandBundle = document.getElementById("bundle_brand");