removed sync making of dirs #445

This commit is contained in:
soulgalore 2014-07-28 09:57:51 +02:00
parent d2cd4b8213
commit 8a0bdc3df8
1 changed files with 24 additions and 11 deletions

View File

@ -70,18 +70,24 @@ Runner.prototype.run = function(finshedCb) {
}
else {
// setup the directories needed
fs.mkdirsSync(path.join(config.run.absResultDir, config.dataDir));
var dataDir = path.join(config.run.absResultDir, config.dataDir);
fs.mkdirs(dataDir, function(err) {
if (err) {
log.log('error', "Couldn't create the data dir:" + dataDir + ' ' + err);
throw err;
} else {
// TODO needs t be stored for sites also
// store the config file, so we can backtrack errors and/or use it again
fs.writeFile(path.join(config.run.absResultDir, 'config.json'), JSON.stringify(
config), function(err) {
if (err) throw err;
});
// TODO needs t be stored for sites also
// store the config file, so we can backtrack errors and/or use it again
fs.writeFile(path.join(config.run.absResultDir, 'config.json'), JSON.stringify(
config), function(err) {
if (err) throw err;
self._fetchData(finshedCb);
}
});
this._fetchData(finshedCb);
}
};
};
Runner.prototype._setupSite = function(args, cb) {
@ -90,8 +96,15 @@ Runner.prototype._setupSite = function(args, cb) {
config.urlObject = urlParser.parse(config.url);
config.run.absResultDir = path.join(__dirname, '../',config.resultBaseDir, 'sites', dateFormat(config.run.date, "yyyy-mm-dd-HH-MM-ss"), config.urlObject.hostname );
// setup the directories needed
fs.mkdirsSync(path.join(config.run.absResultDir, config.dataDir));
args.runner._fetchData(cb);
var dataDir = path.join(config.run.absResultDir, config.dataDir);
fs.mkdirs(dataDir, function (err) {
if (err) {
log.log('error', "Couldn't create the data dir:" + dataDir + ' ' + err);
throw err;
}
else args.runner._fetchData(cb);
});
};
Runner.prototype._fetchData = function(cb) {