mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-04 15:07:21 +01:00
generate id outside of copy task
This commit is contained in:
12
renderer.js
12
renderer.js
@@ -5,8 +5,7 @@ const uuid = require('uuid');
|
|||||||
const {getDirPath, getDocPath} = require('./utils');
|
const {getDirPath, getDocPath} = require('./utils');
|
||||||
|
|
||||||
|
|
||||||
function copyToTemp(texDocument, callback) {
|
function copyToTemp(id, texDocument, callback) {
|
||||||
const id = uuid.v1();
|
|
||||||
const dirPath = getDirPath(id);
|
const dirPath = getDirPath(id);
|
||||||
|
|
||||||
fs.mkdir(dirPath, (err) => {
|
fs.mkdir(dirPath, (err) => {
|
||||||
@@ -20,7 +19,7 @@ function copyToTemp(texDocument, callback) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
callback(null, id);
|
callback(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -42,7 +41,12 @@ function generateDoc(id, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = (texDocument, 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);
|
generateDoc(id, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user