[gnome-ostree/wip/new-model: 6/12] autobuilder: Move srcUrl / component matching to the resolve task



commit 4969458107c78ee9fbe20af4f8320ba98e26a70e
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 |   28 ++++++----------------------
 src/js/tasks/task-resolve.js   |   16 +++++++++++++---
 2 files changed, 19 insertions(+), 25 deletions(-)
---
diff --git a/src/js/builtins/autobuilder.js b/src/js/builtins/autobuilder.js
index b83d646..52dadd9 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,19 +126,8 @@ 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 = srcUrls;
+        this._runResolve();
     },
     
     _triggerFullResolve: function() {
@@ -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..545f1f4 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,23 @@ 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();
+        for (let i = 0; i < this.parameters.fetchSrcUrls.length; i++) {
+            let matches = snapshot.getMatchingSrc(srcUrls[i]);
+            for (let j = 0; j < matches.length; j++) {
+                let name = matches[i]['name'];
+                componentsToFetch.push(name);
+            }
+        }
+
         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]