import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1194415 - Refactor BuildProgressFooter.draw() for minor |mach build| perf improvement, r=gps (3488ffb86)
- Bug 1153691 - intTestLogging() now adds timestamps and supports param substitution. r=rnewman (507a881c2)
- reenable asserts (97032f833)
- re-enable specific Windows optimization (7a581da03)
- Bug 1149815 - Pass storage function failure codes through to callers, r=asuth. (c54838b5d)
- Bug 1149373 - Ensure mozStorage async threads are shut down. r=bent (a511cfefc)
- namespace style (7a567650f)
- Bug 1193022 - clean up reference-counting in storage/; r=mak (49f115c52)
- Bug 1155193 Proxy release the Connection in mozStorageService::unregisterConnection(). r=asuth (bb9311ee5)
- bug 1189896 - Do not preallocate Sqlite connections caches for now. r=asuth (210115e89)
- Bug 1155846 - Comment out intentionally unreachable code and unused parameters in Prefetcher.jsm. r=billm (8757cba52)
- Bug 1166886 - Comment out some code that is supposed to be disabled (r=mconley) (ec5b2bd30)
- Bug 1040285 - Single Quotes should not be encoded in the path r=mcmanus,annevk (0a47fdc2f)
- Bug 1040285 - Single Quotes in HTTP request-uri Are Incorrectly Encoded as %27 r=MattN (dcce00624)
- Bug 1125989 - Avoid OS.File request lossage during worker shutdown, r=yoric (e8e8cab17)
- Bug 1164822 - Fix OS.File.remove not throwing with unexisting files. r=Yoric (dd57a069f)
- Bug 1123372 - Remove use of .toLocaleFormat() from Places. r=mak (fbfbd7fa0)
This commit is contained in:
2021-12-13 09:37:57 +08:00
parent 153837ef4c
commit caf9d19efc
38 changed files with 371 additions and 137 deletions
+19 -1
View File
@@ -218,6 +218,24 @@ this.PlacesBackups = {
}.bind(this));
},
/**
* Generates a ISO date string (YYYY-MM-DD) from a Date object.
*
* @param dateObj
* The date object to parse.
* @return an ISO date string.
*/
toISODateString: function toISODateString(dateObj) {
if (!dateObj || dateObj.constructor.name != "Date" || !dateObj.getTime())
throw new Error("invalid date object");
let padDate = val => ("0" + val).substr(-2, 2);
return [
dateObj.getFullYear(),
padDate(dateObj.getMonth() + 1),
padDate(dateObj.getDate())
].join("-");
},
/**
* Creates a filename for bookmarks backup files.
*
@@ -233,7 +251,7 @@ this.PlacesBackups = {
let dateObj = aDateObj || new Date();
// Use YYYY-MM-DD (ISO 8601) as it doesn't contain illegal characters
// and makes the alphabetical order of multiple backup files more useful.
return "bookmarks-" + dateObj.toLocaleFormat("%Y-%m-%d") + ".json" +
return "bookmarks-" + PlacesBackups.toISODateString(dateObj) + ".json" +
(aCompress ? "lz4" : "");
},
@@ -20,7 +20,7 @@ add_task(function* test_same_date_same_hash() {
// Save JSON file in backup folder with hash appended
let dateObj = new Date();
let filename = "bookmarks-" + dateObj.toLocaleFormat("%Y-%m-%d") + "_" +
let filename = "bookmarks-" + PlacesBackups.toISODateString(dateObj) + "_" +
count + "_" + hash + ".json";
let backupFile = OS.Path.join(backupFolder, filename);
yield OS.File.move(tempPath, backupFile);
@@ -53,7 +53,7 @@ add_task(function* test_same_date_diff_hash() {
"bug10169583_bookmarks.json");
let {count, hash} = yield BookmarkJSONUtils.exportToFile(tempPath);
let dateObj = new Date();
let filename = "bookmarks-" + dateObj.toLocaleFormat("%Y-%m-%d") + "_" +
let filename = "bookmarks-" + PlacesBackups.toISODateString(dateObj) + "_" +
count + "_" + "differentHash==" + ".json";
let backupFile = OS.Path.join(backupFolder, filename);
yield OS.File.move(tempPath, backupFile);
@@ -84,9 +84,9 @@ add_task(function* test_diff_date_same_hash() {
let {count, hash} = yield BookmarkJSONUtils.exportToFile(tempPath);
let oldDate = new Date(2014, 1, 1);
let curDate = new Date();
let oldFilename = "bookmarks-" + oldDate.toLocaleFormat("%Y-%m-%d") + "_" +
let oldFilename = "bookmarks-" + PlacesBackups.toISODateString(oldDate) + "_" +
count + "_" + hash + ".json";
let newFilename = "bookmarks-" + curDate.toLocaleFormat("%Y-%m-%d") + "_" +
let newFilename = "bookmarks-" + PlacesBackups.toISODateString(curDate) + "_" +
count + "_" + hash + ".json";
let backupFile = OS.Path.join(backupFolder, oldFilename);
let newBackupFile = OS.Path.join(backupFolder, newFilename);
@@ -21,7 +21,7 @@ function run_test() {
let dateObj = new Date();
dateObj.setYear(dateObj.getFullYear() + 1);
let name = PlacesBackups.getFilenameForDate(dateObj);
do_check_eq(name, "bookmarks-" + dateObj.toLocaleFormat("%Y-%m-%d") + ".json");
do_check_eq(name, "bookmarks-" + PlacesBackups.toISODateString(dateObj) + ".json");
files = bookmarksBackupDir.directoryEntries;
while (files.hasMoreElements()) {
let entry = files.getNext().QueryInterface(Ci.nsIFile);
@@ -33,7 +33,7 @@ add_task(function() {
do_check_eq(backupFiles.length, 1);
let matches = OS.Path.basename(backupFiles[0]).match(PlacesBackups.filenamesRegex);
do_check_eq(matches[1], new Date().toLocaleFormat("%Y-%m-%d"));
do_check_eq(matches[1], PlacesBackups.toISODateString(new Date()));
do_check_eq(matches[2], count);
do_check_eq(matches[3], hash);
@@ -49,7 +49,7 @@ add_task(function() {
recentBackup = yield PlacesBackups.getMostRecentBackup();
do_check_neq(recentBackup, OS.Path.join(backupFolder, oldBackupName));
matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex);
do_check_eq(matches[1], new Date().toLocaleFormat("%Y-%m-%d"));
do_check_eq(matches[1], PlacesBackups.toISODateString(new Date()));
do_check_eq(matches[2], count + 1);
do_check_neq(matches[3], hash);
@@ -382,7 +382,7 @@ function shutdownPlaces(aKeepAliveConnection)
const FILENAME_BOOKMARKS_HTML = "bookmarks.html";
const FILENAME_BOOKMARKS_JSON = "bookmarks-" +
(new Date().toLocaleFormat("%Y-%m-%d")) + ".json";
(PlacesBackups.toISODateString(new Date())) + ".json";
/**
* Creates a bookmarks.html file in the profile folder from a given source file.
@@ -494,7 +494,7 @@ function check_JSON_backup(aIsAutomaticBackup) {
let bookmarksBackupDir = gProfD.clone();
bookmarksBackupDir.append("bookmarkbackups");
let files = bookmarksBackupDir.directoryEntries;
let backup_date = new Date().toLocaleFormat("%Y-%m-%d");
let backup_date = PlacesBackups.toISODateString(new Date());
while (files.hasMoreElements()) {
let entry = files.getNext().QueryInterface(Ci.nsIFile);
if (PlacesBackups.filenamesRegex.test(entry.leafName)) {
@@ -23,9 +23,8 @@ add_task(function () {
let randomDate = new Date(dateObj.getFullYear() - 1,
Math.floor(12 * Math.random()),
Math.floor(28 * Math.random()));
let dateString = randomDate.toLocaleFormat("%Y-%m-%d");
if (dates.indexOf(dateString) == -1)
dates.push(dateString);
if (dates.indexOf(randomDate.getTime()) == -1)
dates.push(randomDate.getTime());
}
// Sort dates from oldest to newest.
dates.sort();
@@ -49,7 +48,7 @@ add_task(function () {
yield PlacesBackups.create(NUMBER_OF_BACKUPS);
// Add today's backup.
dates.push(dateObj.toLocaleFormat("%Y-%m-%d"));
dates.push(dateObj.getTime());
// Check backups. We have 11 dates but we the max number is 10 so the
// oldest backup should have been removed.