Skip to content

Commit 84c97c1

Browse files
author
Evgheni C.
committed
Merge pull request #13 from rtirserio/master
use mkdir and a callback rather than mkdirSync when writing the sitemap
2 parents fb9ac3b + 61e1468 commit 84c97c1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

routes/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,25 @@ function postAddScraper(req, res)
110110
var sitemap_path = "public/sitemaps/";
111111
fs.exists(sitemap_path, function(exists) {
112112
if (!exists) {
113-
fs.mkdirSync(sitemap_path);
113+
fs.mkdir(sitemap_path, wrtieSitemap);
114+
} else {
115+
wrtieSitemap();
114116
}
117+
118+
// Terminate crawling daemon
119+
child.kill();
120+
});
121+
function wrtieSitemap() {
115122
var filename = "sitemap_"+ data.host +".xml";
116123
fs.writeFile(sitemap_path + filename, data.content, function(err)
117124
{
118125
if(err)
119126
console.log(err);
120127
else
121128
io.sockets.emit('sitemap-ready', {path: sitemap_path.replace("public/", "")})
129+
});
122130

123-
// Terminate crawling daemon
124-
child.kill();
125-
});
126-
});
131+
}
127132
break;
128133
}
129134
})

0 commit comments

Comments
 (0)