@@ -59,7 +59,7 @@ class FileOps
5959 { toRemove : {}} , nil , noLoad, FileOps . logger
6060 return FileOps . config
6161
62- remove : ( paths, reSchedule = false ) ->
62+ remove : ( paths, recurse , reSchedule ) ->
6363 config = createConfig true
6464 configLoaded, res = false , {}
6565 paths = { paths} unless type ( paths) == " table"
@@ -68,7 +68,7 @@ class FileOps
6868 mode, path = FileOps . attributes path, " mode"
6969 if mode
7070 rmFunc = mode == " file" and os.remove or FileOps . rmdir
71- success, err = rmFunc path
71+ success, err = rmFunc path, recurse
7272 if not success
7373 unless reSchedule
7474 res[ # res+ 1 ] = { nil , err}
@@ -89,7 +89,7 @@ class FileOps
8989 paths = [ path for path, _ in pairs config. c. toRemove]
9090 if # paths > 0
9191 -- rescheduled removals will not be rescheduled another time
92- FileOps . remove paths
92+ FileOps . remove paths, true
9393 config. c. toRemove = {}
9494 config\ write!
9595 return true
@@ -120,20 +120,21 @@ class FileOps
120120 -- at this point the target directory exists and the target file doesn't, move the file
121121 res, err = os.rename source, target
122122 unless res -- renaming the file failed, probably a permission issue
123- return false , msgs. move. cantRename, source, target, err
123+ return false , msgs. move. cantRename\ format source, target, err
124124
125125 return true
126126
127- rmdir : ( path) ->
127+ rmdir : ( path, recurse = true ) ->
128128 return nil , msgs. rmdir. emptyPath if path == " "
129129 mode, path = FileOps . attributes path, " mode"
130130 return nil , msgs. rmdir. notPath unless mode == " directory"
131131
132- -- recursively remove contained files and directories
133- toRemove = [ " #{path}/#{file}" for file in lfs. dir path]
134- res, err = FileOps . remove toRemove, false
135- if err
136- return nil , msgs. rmdir. couldntRemoveFiles, res
132+ if recurse
133+ -- recursively remove contained files and directories
134+ toRemove = [ " #{path}/#{file}" for file in lfs. dir path]
135+ res, err = FileOps . remove toRemove, true
136+ if err
137+ return nil , msgs. rmdir. couldntRemoveFiles, res
137138
138139 -- remove empty directory
139140 success, err = lfs. rmdir path
0 commit comments