Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Commit

Permalink
remove tmp file
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtk75 committed Jun 22, 2013
1 parent ccd2f61 commit 7404649
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions routes/images.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ module.exports = (ctx)->
title.stdout.on 'data', stdouth
title.stderr.on 'data', (data)-> res.write data

unlink = ->
fs.unlink info.path, (err)->
unlink = (path)->
fs.unlink path, (err)->
if err
console.err "unlink: #{err}"
else
console.log "removed: #{info.path}"
console.log "unlink: #{path}"

title.on 'close', (code)->
if filepath
fs.readFile filepath.trim(), flags:"rb", (err, data)->
throw err if err
res.write data
res.end()
unlink()
unlink info.path
unlink filepath.trim()
else
res.end()
unlink()
unlink info.path

0 comments on commit 7404649

Please sign in to comment.