[gnome-ostree/wip/gjs-round2] task: Limit retained tasks to 10 for now
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree/wip/gjs-round2] task: Limit retained tasks to 10 for now
- Date: Sat, 15 Dec 2012 16:06:07 +0000 (UTC)
commit ae658048fbbbb4385f26a5efdafb33c911e4e4dd
Author: Colin Walters <walters verbum org>
Date: Sat Dec 15 11:04:31 2012 -0500
task: Limit retained tasks to 10 for now
Otherwise they accumulate way too quickly, and old build logs are only
mildly interesting.
src/ostbuild/js/task.js | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/ostbuild/js/task.js b/src/ostbuild/js/task.js
index 464e283..286dbc3 100644
--- a/src/ostbuild/js/task.js
+++ b/src/ostbuild/js/task.js
@@ -80,22 +80,33 @@ const TaskSet = new Lang.Class({
this._history = [];
this._running = false;
this._running_version = null;
+ this._maxVersions = 10;
this._load();
},
+ _cleanOldEntries: function() {
+ while (this._history.length > this._maxVersions) {
+ let task = this._history.shift();
+ GSystem.shutil_rm_rf(task.path, null);
+ }
+ },
+
_load: function() {
var e = this.path.enumerate_children('standard::*', Gio.FileQueryInfoFlags.NONE, null);
let info;
+ let history = [];
while ((info = e.next_file(null)) != null) {
let name = info.get_name();
let childPath = this.path.get_child(name);
let match = VERSION_RE.exec(name);
if (!match)
continue;
- this._history.push(new TaskHistoryEntry(childPath))
+ history.push(new TaskHistoryEntry(childPath))
}
- this._history.sort(TaskHistoryEntry.prototype.compareTo);
+ history.sort(TaskHistoryEntry.prototype.compareTo);
+ this._history = history;
+ this._cleanOldEntries();
},
start: function() {
@@ -123,6 +134,7 @@ const TaskSet = new Lang.Class({
let last = this._history[this._history.length-1];
last.finish(success);
this._running = false;
+ this._cleanOldEntries();
},
getHistory: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]