[gnome-ostree] autobuilder: Move srcUrl / component matching to the resolve task



commit 3444fea019eb81cb5625173f967c564c0b06f88f
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 9ca4aea..d4afa6d 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">
@@ -47,7 +45,7 @@ const Autobuilder = new Lang.Class({
        this._initialResolveNeeded = true;
        this._fullResolveNeeded = true;
        this._resolveTimeout = 0;
-       this._queuedForceResolve = [];
+       this._resolveSrcUrls = [];
     },
 
     execute: function(args, loop, cancellable) {
@@ -63,9 +61,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) });
        this._taskmaster.connect('task-executing', Lang.bind(this, this._onTaskExecuting));
@@ -128,21 +123,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();
@@ -153,7 +137,7 @@ const Autobuilder = new Lang.Class({
        let cancellable = null;
        
        if (!(this._initialResolveNeeded ||
-             this._queuedForceResolve.length > 0 ||
+             this._resolveSrcUrls.length > 0 ||
              this._fullResolveNeeded))
            return;
 
@@ -171,9 +155,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]