delete directory with rimraf

This commit is contained in:
Brian Gough 2014-12-19 16:58:04 +00:00
parent af4c72150f
commit 8744cf94a5
2 changed files with 6 additions and 4 deletions

View file

@ -1,6 +1,7 @@
logger = require("logger-sharelatex")
fs = require("fs")
LocalFileWriter = require("./LocalFileWriter")
rimraf = require("rimraf")
filterName = (key) ->
return key.replace /\//g, "_"
@ -57,10 +58,10 @@ module.exports =
callback err
deleteDirectory: (location, name, callback = (err)->)->
filteredName = filterName name
fs.rmdir "#{location}/#{filteredName}", (err) ->
logger.err err:err, location:location, name:filteredName, "Error on rmdir."
if err and err.code != 'ENOENT'
filteredName = filterName name.replace(/\/$/,'')
rimraf "#{location}/#{filteredName}", (err) ->
if err
logger.err err:err, location:location, name:filteredName, "Error on rimraf rmdir."
callback err
else
callback()

View file

@ -21,6 +21,7 @@
"node-uuid": "~1.4.1",
"pngcrush": "0.0.3",
"request": "2.14.0",
"rimraf": "2.2.8",
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#master",
"stream-buffers": "~0.2.5",
"underscore": "~1.5.2"