From 77174e77a7a4dc1eca61d40667af4e1772b5b1ac Mon Sep 17 00:00:00 2001 From: Magnus Melin Date: Mon, 1 Aug 2022 14:31:03 +1000 Subject: [PATCH] Bug 1780549 - Disable Repair Folder for IMAP folders when in offline mode. r=benc Differential Revision: https://phabricator.services.mozilla.com/D152960 --HG-- extra : rebase_source : 4608a2bb45f3b9a10fd37186527f9671c0ac191d extra : amend_source : 9a76a706869b14887bdb19325bcd97988f398b5d --- mail/base/content/folderPane.js | 14 ++++---------- mailnews/base/content/folderProps.js | 26 ++++++++++++++------------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/mail/base/content/folderPane.js b/mail/base/content/folderPane.js index b357eebb1f..105d376617 100644 --- a/mail/base/content/folderPane.js +++ b/mail/base/content/folderPane.js @@ -3406,22 +3406,16 @@ var gFolderTreeController = { } } - // xxx useless param - function rebuildSummary(aFolder) { - // folder is already introduced in our containing function and is - // lexically captured and available to us. + async function rebuildSummary() { if (folder.locked) { folder.throwAlertMsg("operationFailedFolderBusy", msgWindow); return; } if (folder.supportsOffline) { // Remove the offline store, if any. - let offlineStore = folder.filePath; - // XXX todo: figure out how to delete a maildir directory async. This - // delete causes main thread lockup for large maildir folders. - if (offlineStore.exists()) { - offlineStore.remove(true); - } + await IOUtils.remove(folder.filePath.path, { recursive: true }).catch( + Cu.reportError + ); } // We may be rebuilding a folder that is not the displayed one. diff --git a/mailnews/base/content/folderProps.js b/mailnews/base/content/folderProps.js index d54f43df4e..2505d34ef3 100644 --- a/mailnews/base/content/folderProps.js +++ b/mailnews/base/content/folderProps.js @@ -18,8 +18,12 @@ window.addEventListener("DOMContentLoaded", folderPropsOnLoad); document.addEventListener("dialogaccept", folderPropsOKButton); document.addEventListener("dialogcancel", folderCancelButton); -// The folderPropsSink is the class that gets notified of an imap folder's properties - +/** + * The folderPropsSink is the class that gets notified of an imap folder's + * properties. + * + * @implements {nsIMsgImapFolderProps} + */ var gFolderPropsSink = { setFolderType(folderTypeString) { var typeLabel = document.getElementById("folderType.text"); @@ -243,8 +247,6 @@ function folderPropsOnLoad() { gMsgFolder, "folderIconColor" ); - } else { - dump("passed null for folder, do nothing\n"); } if (window.arguments[0].name) { @@ -253,9 +255,6 @@ function folderPropsOnLoad() { // when the dialog is accepted. var nameTextbox = document.getElementById("name"); nameTextbox.value = window.arguments[0].name; - - // name.setSelectionRange(0,-1); - // name.focusTextField(); } const serverType = window.arguments[0].serverType; @@ -346,10 +345,8 @@ function folderPropsOnLoad() { } if (serverType == "imap") { - var imapFolder = gMsgFolder.QueryInterface(Ci.nsIMsgImapMailFolder); - if (imapFolder) { - imapFolder.fillInFolderProps(gFolderPropsSink); - } + let imapFolder = gMsgFolder.QueryInterface(Ci.nsIMsgImapMailFolder); + imapFolder.fillInFolderProps(gFolderPropsSink); let users = [...imapFolder.getOtherUsersWithAccess()]; if (users.length) { @@ -358,6 +355,11 @@ function folderPropsOnLoad() { ", " ); } + + // Disable "Repair Folder" when offline as that would cause the offline store + // to get deleted and redownloaded. + document.getElementById("folderRebuildSummaryButton").disabled = + gMsgFolder.supportsOffline && Services.io.offline; } var retentionSettings = gMsgFolder.retentionSettings; @@ -475,5 +477,5 @@ function onUseDefaultRetentionSettings() { } function RebuildSummaryInformation() { - window.arguments[0].rebuildSummaryCallback(gMsgFolder); + window.arguments[0].rebuildSummaryCallback(); }