[gnome-ostree/wip/new-model: 29/34] autobuilder: Move srcUrl / component matching to the resolve task
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-ostree/wip/new-model: 29/34] autobuilder: Move srcUrl / component matching to the resolve task
- Date: Thu, 11 Jul 2013 17:17:01 +0000 (UTC)
commit 473309b7e1ca2a9261800914602c116d60adb7b4
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Jun 19 16:47:55 2013 -0400
autobuilder: Move srcUrl / component matching to the resolve task
This removes one use of JsonDB.
src/js/builtins/autobuilder.js | 30 +++++++-----------------------
src/js/tasks/task-resolve.js | 14 +++++++++++---
2 files changed, 18 insertions(+), 26 deletions(-)
---
diff --git a/src/js/builtins/autobuilder.js b/src/js/builtins/autobuilder.js
index b83d646..7a56812 100644
--- a/src/js/builtins/autobuilder.js
+++ b/src/js/builtins/autobuilder.js
@@ -21,9 +21,7 @@ const Lang = imports.lang;
const Builtin = imports.builtin;
const Task = imports.task;
-const JsonDB = imports.jsondb;
const ProcUtil = imports.procutil;
-const Snapshot = imports.snapshot;
var AutoBuilderIface = <interface name="org.gnome.OSTreeBuild.AutoBuilder">
<method name="queueResolve">
@@ -49,7 +47,7 @@ const Autobuilder = new Lang.Class({
this._initialResolveNeeded = true;
this._fullResolveNeeded = true;
this._resolveTimeout = 0;
- this._queuedForceResolve = [];
+ this._resolveSrcUrls = [];
},
execute: function(args, loop, cancellable) {
@@ -65,9 +63,6 @@ const Autobuilder = new Lang.Class({
this._impl = Gio.DBusExportedObject.wrapJSObject(AutoBuilderIface, this);
this._impl.export(Gio.DBus.session, '/org/gnome/OSTreeBuild/AutoBuilder');
- this._snapshot_dir = this.workdir.get_child('snapshots');
- this._src_db = new JsonDB.JsonDB(this._snapshot_dir);
-
this._taskmaster = new Task.TaskMaster(this.workdir.get_child('tasks'),
{ onEmpty: Lang.bind(this, this._onTasksComplete),
skip: args.skip });
@@ -131,21 +126,10 @@ const Autobuilder = new Lang.Class({
},
queueResolve: function(srcUrls) {
- let matchingComponents = [];
- let latestPath = this._src_db.getLatestPath();
- let snapshotData = this._src_db.loadFromPath(latestPath, null);
- let snapshot = new Snapshot.Snapshot(snapshotData, latestPath);
- for (let i = 0; i < srcUrls.length; i++) {
- let matches = snapshot.getMatchingSrc(srcUrls[i]);
- for (let j = 0; j < matches.length; j++) {
- let name = matches[i]['name'];
- this._queuedForceResolve.push(name);
- print("Queued force resolve for " + name);
- }
- }
- this._runResolve();
+ this._resolveSrcUrls.push.apply(srcUrls);
+ this._runResolve();
},
-
+
_triggerFullResolve: function() {
this._fullResolveNeeded = true;
this._runResolve();
@@ -156,7 +140,7 @@ const Autobuilder = new Lang.Class({
let cancellable = null;
if (!(this._initialResolveNeeded ||
- this._queuedForceResolve.length > 0 ||
+ this._resolveSrcUrls.length > 0 ||
this._fullResolveNeeded))
return;
@@ -174,9 +158,9 @@ const Autobuilder = new Lang.Class({
this._fullResolveNeeded = false;
this._taskmaster.pushTask('resolve', { fetchAll: true });
} else {
- this._taskmaster.pushTask('resolve', { fetchComponents: this._queuedForceResolve });
+ this._taskmaster.pushTask('resolve', { fetchSrcUrls: this._resolveSrcUrls });
}
- this._queuedForceResolve = [];
+ this._resolveSrcUrls = [];
this._updateStatus();
}
diff --git a/src/js/tasks/task-resolve.js b/src/js/tasks/task-resolve.js
index 242749e..94d334c 100644
--- a/src/js/tasks/task-resolve.js
+++ b/src/js/tasks/task-resolve.js
@@ -34,6 +34,7 @@ const TaskResolve = new Lang.Class({
},
DefaultParameters: {fetchAll: false,
+ fetchSrcUrls: [],
fetchComponents: [],
timeoutSec: 10},
@@ -49,14 +50,21 @@ const TaskResolve = new Lang.Class({
let manifestPath = this.workdir.get_child('manifest.json');
let data = JsonUtil.loadJson(manifestPath, cancellable);
this._snapshot = new Snapshot.Snapshot(data, manifestPath, { prepareResolve: true });
-
+
+ let componentsToFetch = this.parameters.fetchComponents.slice();
+ let srcUrls = this.parameters.fetchSrcUrls;
+ for (let i = 0; i < srcUrls; i++) {
+ let matches = snapshot.getMatchingSrc(srcUrls[i]);
+ componentsToFetch.push.apply(matches);
+ }
+
let gitMirrorArgs = ['ostbuild', 'git-mirror', '--timeout-sec=' + this.parameters.timeoutSec,
'--workdir=' + this.workdir.get_path(),
'--manifest=' + manifestPath.get_path()];
- if (this.parameters.fetchAll || this.parameters.fetchComponents.length > 0) {
+ if (this.parameters.fetchAll || componentsToFetch.length > 0) {
gitMirrorArgs.push('--fetch');
gitMirrorArgs.push('-k');
- gitMirrorArgs.push.apply(gitMirrorArgs, this.parameters.fetchComponents);
+ gitMirrorArgs.push.apply(gitMirrorArgs, componentsToFetch);
}
ProcUtil.runSync(gitMirrorArgs, cancellable, { logInitiation: true });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]