[gnome-ostree] task: Remove queryVersion



commit 1d5feb3475b3f418db879b4f8902e014202f5de7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Jun 13 18:13:30 2013 -0400

    task: Remove queryVersion
    
    The point of it was to determine whether the task "changed". Just
    have the task tell us directly by writing out a file. In the future,
    we should probably merge all of the "status" results of the task
    into one file, but let's keep this as is for now.

 src/js/task.js               |   29 ++++++++---------------------
 src/js/tasks/task-resolve.js |    7 +++----
 2 files changed, 11 insertions(+), 25 deletions(-)
---
diff --git a/src/js/task.js b/src/js/task.js
index 7f54dae..14c82f3 100644
--- a/src/js/task.js
+++ b/src/js/task.js
@@ -117,8 +117,6 @@ const TaskMaster = new Lang.Class({
 
        this._taskset = TaskSet.prototype.getInstance();
 
-       this._taskVersions = {};
-
        // string -> [ lastExecutedSecs, [timeoutId, parameters]]
        this._scheduledTaskTimeouts = {};
     },
@@ -261,16 +259,7 @@ const TaskMaster = new Lang.Class({
        this._executing.splice(idx, 1);
        this.emit('task-complete', runner, success, error);
        if (success && this._processAfter) {
-           let changed = true;
-           let version = runner.taskDef.queryVersion();
-           if (version !== null) {
-               let oldVersion = this._taskVersions[runner.taskDef.name];
-               if (oldVersion == version)
-                   changed = false;
-               else if (oldVersion != null)
-                   print("task " + runner.taskDef.name + " new version: " + version);
-           }
-           if (changed) {
+           if (runner.changed) {
                let tasksAfter = this._taskset.getTasksAfter(task.name);
                for (let i = 0; i < tasksAfter.length; i++) {
                    let after = tasksAfter[i];
@@ -288,11 +277,6 @@ const TaskMaster = new Lang.Class({
               this._pendingTasksList.length > 0 &&
               !this.isTaskExecuting(this._pendingTasksList[0].name)) {
            let task = this._pendingTasksList.shift();
-           let version = task.queryVersion();
-           if (version !== null) {
-               this._taskVersions[task.name] = version;
-           }
-
            let runner = new TaskRunner(this, task, Lang.bind(this, function(success, error) {
                this._onComplete(success, error, runner);
            }));
@@ -339,10 +323,6 @@ const TaskDef = new Lang.Class({
        return new JsonDB.JsonDB(path);
     },
 
-    queryVersion: function() {
-       return null;
-    },
-
     execute: function(cancellable) {
        throw new Error("Not implemented");
     },
@@ -489,6 +469,13 @@ const TaskRunner = new Lang.Class({
        let [success, errmsg] = ProcUtil.asyncWaitCheckFinish(proc, result);
        let target;
 
+        this.changed = true;
+        let modifiedPath = this._taskCwd.get_child('modified.json');
+        if (modifiedPath.query_exists(null)) {
+            let data = JsonUtil.loadJson(modifiedPath);
+            this.changed = data['modified'];
+        }
+
        if (!success) {
            target = this._failedDir.get_child(this._version);
            GSystem.file_rename(this._taskCwd, target, null);
diff --git a/src/js/tasks/task-resolve.js b/src/js/tasks/task-resolve.js
index 4d6a401..7541b60 100644
--- a/src/js/tasks/task-resolve.js
+++ b/src/js/tasks/task-resolve.js
@@ -50,10 +50,6 @@ const TaskResolve = new Lang.Class({
        return this._db;
     },
 
-    queryVersion: function() {
-       return this._getDb().getLatestVersion();
-    },
-
     execute: function(cancellable) {
         let manifestPath = this.workdir.get_child('manifest.json');
        let data = JsonUtil.loadJson(manifestPath, cancellable);
@@ -84,5 +80,8 @@ const TaskResolve = new Lang.Class({
         } else {
             print("Source snapshot unchanged: " + path.get_path());
        }
+
+        let modifiedPath = Gio.File.new_for_path('modified.json');
+        JsonUtil.writeJsonFileAtomic(modifiedPath, { modified: modified }, cancellable);
     }
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]