Skip to content

Commit

Permalink
fix: Cleanup fail after build
Browse files Browse the repository at this point in the history
Probably it is a fix

Closes #724
  • Loading branch information
develar committed Sep 7, 2016
1 parent 87616c0 commit 2e35205
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/util/tmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,23 @@ export class TmpDir {
}

return this.tempDirectoryPromise
.then(it => path.join(it, `temp-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
.then(it => path.join(it, `t-${process.pid.toString(16)}-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
}

cleanup(): Promise<any> {
if (this.dir == null) {
const dir = this.dir
if (dir == null) {
return BluebirdPromise.resolve()
}

return remove(this.dir)
.then(() => {
this.dir = null
})
this.dir = null
return remove(dir)
.catch(e => {
if (e.code !== "EPERM") {
warn(`Cannot delete temporary dir "${this.dir}": ${(e.stack || e).toString()}`)
if (e.code === "EPERM") {
this.dir = dir
}
else {
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
}
})
}
Expand Down

0 comments on commit 2e35205

Please sign in to comment.