From a2cd450cbedc763d563731f5b9850d55177493f8 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Tue, 3 Apr 2012 16:26:40 +0100 Subject: [PATCH] Track source filepath for tiddlers in tiddler file store --- js/FileStore.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/js/FileStore.js b/js/FileStore.js index e7d8d4675..156d220d3 100644 --- a/js/FileStore.js +++ b/js/FileStore.js @@ -18,6 +18,7 @@ function FileStore(dirpath,store,callback) { this.dirpath = dirpath; this.store = store; this.callback = callback; + this.sources = {}; // A hashmap of : var self = this; // Set up a queue for loading tiddler files this.loadQueue = async.queue(function(task,callback) { @@ -27,8 +28,7 @@ function FileStore(dirpath,store,callback) { } else { // Use the filepath as the default title and src for the tiddler var fields = { - title: data.path, - src: data.path + title: data.path }; var tiddlers = self.store.deserializeTiddlers(data.extname,data.text,fields); // Check for the .meta file @@ -45,12 +45,12 @@ function FileStore(dirpath,store,callback) { fields = self.store.deserializeTiddlers("application/x-tiddler",text,fields)[0]; } } - self.store.addTiddler(fields); + task.callback(task,[fields]); callback(null); } }); } else { - self.store.addTiddlers(tiddlers); + task.callback(task,tiddlers); callback(null); } } @@ -69,7 +69,14 @@ function FileStore(dirpath,store,callback) { var f = files[t]; if(["..",".",".DS_Store"].indexOf(f) === -1 && f.indexOf(".meta") !== f.length-5) { self.loadQueue.push({ - filepath: path.resolve(self.dirpath,f) + filepath: path.resolve(self.dirpath,f), + callback: function(task,tiddlers) { + for(var t=0; t