Skip to content

Commit

Permalink
Use async version of mkdir-recursive, fix #1493
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Oct 20, 2020
1 parent c36b224 commit d8d1a34
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/handlers/patch.js
Expand Up @@ -60,7 +60,16 @@ async function patchHandler (req, res, next) {
const pathSplit = path.split('/')
const directory = pathSplit.slice(0, pathSplit.length - 1).join('/')
if (!fs.existsSync(directory)) {
fx.mkdirSync(directory, { recursive: true })
debug('PATCH -- mkdirp <%s>', directory)
await new Promise((resolve, reject) => {
fx.mkdir(directory, { recursive: true }, (err) => {
if (err) {
reject(err)
} else {
resolve()
}
})
})
}

// Patch the graph and write it back to the file
Expand Down Expand Up @@ -96,6 +105,7 @@ function readGraph (resource) {
if (err.code === 'ENOENT') {
fileContents = ''
// Fail on all other errors
debug('PATCH to create')
} else {
return reject(error(500, `Original file read error: ${err}`))
}
Expand Down

0 comments on commit d8d1a34

Please sign in to comment.