Bug 462197 - Part 2: The "Remove All Reports" button in about:crashes should remove old InstallTime files. r=ted

This commit is contained in:
Jonathan Watt 2013-01-16 18:03:05 -05:00
parent 4cbf1615c8
commit 673b92d3ee

View File

@ -9,6 +9,9 @@ var reportsDir, submittedDir, pendingDir;
var reportURL;
Components.utils.import("resource://gre/modules/CrashSubmit.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const buildID = Services.appinfo.appBuildID;
function submitSuccess(dumpid, ret) {
let link = document.getElementById(dumpid);
@ -212,6 +215,17 @@ function clearReports() {
file.remove(false);
}
}
entries = reportsDir.directoryEntries;
var oneYearAgo = Date.now() - 31586000000;
while (entries.hasMoreElements()) {
var file = entries.getNext().QueryInterface(Ci.nsIFile);
var leaf = file.leafName;
if (leaf.substr(0, 11) == "InstallTime" &&
file.lastModifiedTime < oneYearAgo &&
leaf != "InstallTime" + buildID) {
file.remove(false);
}
}
document.getElementById("clear-reports").style.display = "none";
document.getElementById("reportList").style.display = "none";
document.getElementById("noReports").style.display = "block";