Bug 462197 - Part 2: The "Remove All Reports" button in about:crashes should remove old InstallTime files. r=ted
authorJonathan Watt <jwatt@jwatt.org>
Wed, 16 Jan 2013 18:03:05 -0500
changeset 119082 fbe92fdbabc70f48c7d1058a027723387a201c16
parent 119081 be9dfaa088b293672ecbdd98e513ae6ddfb715d5
child 119083 eca602d98d14228d8c1d2462f4f4462d74ed6147
push id24189
push useremorley@mozilla.com
push dateThu, 17 Jan 2013 10:42:06 +0000
treeherdermozilla-central@712eca11a04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs462197
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 462197 - Part 2: The "Remove All Reports" button in about:crashes should remove old InstallTime files. r=ted
toolkit/crashreporter/content/crashes.js
--- a/toolkit/crashreporter/content/crashes.js
+++ b/toolkit/crashreporter/content/crashes.js
@@ -4,16 +4,19 @@
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 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);
   if (link) {
     link.className = "";
     // reset the link to point at our new crash report. this way, if the
     // user clicks "Back", the link will be correct.
     let CrashID = ret.CrashID;
@@ -207,16 +210,27 @@ function clearReports() {
   while (entries.hasMoreElements()) {
     var file = entries.getNext().QueryInterface(Ci.nsIFile);
     var leaf = file.leafName;
     if (leaf.substr(0, 3) == "bp-" &&
         leaf.substr(-4) == ".txt") {
       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";
 }
 
 function init() {
   populateReportList();
 }