generate id outside of copy task

This commit is contained in:
Thomas Ruoff
2017-02-20 23:00:18 +01:00
parent 5c6310e848
commit 6c22c94f41

View File

@@ -5,8 +5,7 @@ const uuid = require('uuid');
const {getDirPath, getDocPath} = require('./utils');
function copyToTemp(texDocument, callback) {
const id = uuid.v1();
function copyToTemp(id, texDocument, callback) {
const dirPath = getDirPath(id);
fs.mkdir(dirPath, (err) => {
@@ -20,7 +19,7 @@ function copyToTemp(texDocument, callback) {
if (err) {
callback(err);
}
callback(null, id);
callback(null);
});
});
}
@@ -42,7 +41,12 @@ function generateDoc(id, callback) {
}
module.exports = (texDocument, callback) => {
copyToTemp(texDocument, (err, id) => {
const id = uuid.v1();
copyToTemp(id, texDocument, (err) => {
if (err) {
callback(err);
return;
}
generateDoc(id, callback);
});
};