Bug 1168728
MozReview-Commit-ID: 9uMi92iTXPD
--- a/toolkit/components/telemetry/TelemetryStorage.jsm
+++ b/toolkit/components/telemetry/TelemetryStorage.jsm
@@ -981,29 +981,35 @@ var TelemetryStorageImpl = {
submitProbes(Math.round(archiveSizeInBytes / 1024 / 1024), 0, 0);
return;
}
this._log.info("_enforceArchiveQuota - archive size: " + archiveSizeInBytes + "bytes"
+ ", safety quota: " + SAFE_QUOTA + "bytes");
startTimeStamp = Policy.now().getTime();
- let pingsToPurge = pingList.slice(lastPingIndexToKeep + 1);
- // Remove all the pings older than the last one which we are safe to keep.
- for (let ping of pingsToPurge) {
- if (this._shutdown) {
- this._log.trace("_enforceArchiveQuota - Terminating the clean up task due to shutdown");
- return;
- }
-
+ // If the last one is newest and it's outdated, the rest are as well, so we remove the whole directory
+ if (pingList.length-1==lastPingIndexToKeep){
+ this._log.trace("_removeArchivedPing - removing directory from: " + gPingsArchivePath);
+ this._archivedPings.clear();
+ OS.File.removeDir(gPingsArchivePath);
+ }else {
+ // Remove all the pings older than the last one which we are safe to keep.
+ let pingsToPurge = pingList.slice(lastPingIndexToKeep + 1);
+ for (let ping of pingsToPurge) {
+ if (this._shutdown) {
+ this._log.trace("_enforceArchiveQuota - Terminating the clean up task due to shutdown");
+ return;
+ }
// This list is guaranteed to be in order, so remove the pings at its
// beginning (oldest).
- yield this._removeArchivedPing(ping.id, ping.timestampCreated, ping.type);
- }
+ yield this._removeArchivedPing(ping.id, ping.timestampCreated, ping.type);
+ }
+ }
const endTimeStamp = Policy.now().getTime();
submitProbes(ARCHIVE_SIZE_PROBE_SPECIAL_VALUE, pingsToPurge.length,
Math.ceil(endTimeStamp - startTimeStamp));
}),
_cleanArchive: Task.async(function*() {
this._log.trace("cleanArchiveTask");