From 673b92d3eeedaec9a2a2c2c46b52c6370e67eb83 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Wed, 16 Jan 2013 18:03:05 -0500 Subject: [PATCH] Bug 462197 - Part 2: The "Remove All Reports" button in about:crashes should remove old InstallTime files. r=ted --- toolkit/crashreporter/content/crashes.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/toolkit/crashreporter/content/crashes.js b/toolkit/crashreporter/content/crashes.js index b4ebf1b221d2..30a4dfed4a85 100644 --- a/toolkit/crashreporter/content/crashes.js +++ b/toolkit/crashreporter/content/crashes.js @@ -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";