Bug 1920339 - migrate invalid feed hostnames. r=tobyp
This migrates invalid feeds names to use our standard Feeds. I found even Thunderbid 5.0 uses "Feeds" at least normally... so might not be super common. For testing, set up a feed account. with Thunderbird closed set the hostname to "RSS-News & Weblogs" in prefs.js and edit feeds.json for that account to have destFolder like "mailbox://nobody@RSS-News & Weblogs/comm-central%20Changelog". Also make sure the mail.ui-rdf.version pref is less than 45 (if you're testing more than once). After starting, the hostname should be corrected, and the feeds.json contain good url. Do another restart Thunderbird, and the feeds should now work properly. Differential Revision: https://phabricator.services.mozilla.com/D223317 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
004297a431
Коммит
2e8b2146f5
|
@ -15,6 +15,7 @@ const lazy = {};
|
|||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
EventEmitter: "resource://gre/modules/EventEmitter.sys.mjs",
|
||||
clearXULToolbarState: "resource:///modules/ToolbarMigration.sys.mjs",
|
||||
MailUtils: "resource:///modules/MailUtils.sys.mjs",
|
||||
migrateToolbarForSpace: "resource:///modules/ToolbarMigration.sys.mjs",
|
||||
setTimeout: "resource://gre/modules/Timer.sys.mjs",
|
||||
});
|
||||
|
@ -27,7 +28,7 @@ export var MailMigrator = {
|
|||
_migrateUI() {
|
||||
// The code for this was ported from
|
||||
// mozilla/browser/components/nsBrowserGlue.js
|
||||
const UI_VERSION = 44;
|
||||
const UI_VERSION = 45;
|
||||
const UI_VERSION_PREF = "mail.ui-rdf.version";
|
||||
let currentUIVersion = Services.prefs.getIntPref(UI_VERSION_PREF, 0);
|
||||
|
||||
|
@ -169,6 +170,45 @@ export var MailMigrator = {
|
|||
}
|
||||
}
|
||||
|
||||
if (currentUIVersion < 45) {
|
||||
// Fix bad hostName for feeds in anchient profiles.
|
||||
// Newer profiles use a valid hostname which is Feeds, Feeds-2 etc.
|
||||
// This migration is a bit of a hack and for proper functionality
|
||||
// of these feeds, a restart will be required...
|
||||
let i = 2;
|
||||
const migrations = [];
|
||||
for (const server of MailServices.accounts.accounts
|
||||
.map(a => a.incomingServer)
|
||||
.filter(s => s.type == "rss" && !s.hostName.startsWith("Feeds"))) {
|
||||
server.QueryInterface(Ci.nsIRssIncomingServer);
|
||||
const path = server.subscriptionsPath.path;
|
||||
const migrateJSON = async () => {
|
||||
const feeds = await IOUtils.readJSON(path);
|
||||
let hostname = "Feeds"; // What the corrected hostname will be.
|
||||
while (
|
||||
MailServices.accounts.findServer("nobody", hostname, "rss")
|
||||
) {
|
||||
// If "Feeds" exists, try "Feeds-2", then "Feeds-3", etc.
|
||||
hostname = "Feeds-" + i++;
|
||||
}
|
||||
for (const feed of feeds) {
|
||||
// Values are like "mailbox://nobody@RSS-News & Weblogs/comm-central%20Changelog"
|
||||
feed.destFolder = feed.destFolder.replace(
|
||||
/mailbox:\/\/([^@])+[^\/]+/,
|
||||
`mailbox://nobody@${hostname}`
|
||||
);
|
||||
}
|
||||
await IOUtils.writeJSON(path, feeds);
|
||||
server.hostName = hostname;
|
||||
};
|
||||
migrations.push(migrateJSON());
|
||||
}
|
||||
// Restart after migrations, as the UI can't really handle this.
|
||||
Promise.all(migrations).then(() => {
|
||||
lazy.MailUtils.restartApplication();
|
||||
});
|
||||
}
|
||||
|
||||
// Migration tasks that may take a long time are not run immediately, but
|
||||
// added to the MigrationTasks object then run at the end.
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче