binarykitchen / find-remove

recursively finds files by filter options from a start directory onwards and deletes these. useful if you want to clean up a directory in your node.js app.
https://npmjs.org/package/find-remove
61 stars 19 forks source link

return value is never correct #7

Closed duanmao closed 8 years ago

duanmao commented 8 years ago

the returned array is always empty. due to it's declared as an array (line 128): var removed = []; however when adding filePath to it, it's used as a dictionary (line 167): removed[currentFile] = true;

this is... such an obvious bug.. i'm shocked it has never been fixed in so many releases...

binarykitchen commented 8 years ago

@duanmao hmmm, thanks but i am not sure i understand you. can you be a bit more specific?

what parameters were you using and what return value did you expect? need a reproducible case here

duanmao commented 8 years ago

var deletedFiles = findRemoveSync('downloads/', { age: {seconds: 10}, extensions: '.csv'}) deletedFiles is always empty.

i'm using the latest version 0.2.12, just refer to the line i pointed out, you should be able to find corresponding code I pasted in my initial description. the removed variable has never been successfully added with elements.

binarykitchen commented 8 years ago

@duanmao ok, the age parameter is set to 10 seconds. maybe the csv files in your downloads folder are older than 10 seconds and that's why the deletedFiles array is empty?

have you tried removing the age option to see if that makes a difference?

duanmao commented 8 years ago

... i've already made sure that there're files to remove.. I even debugged into your code to see whether it run through the code of deleting files and adding the file path to removed array. it turns out the file can be found and deleted, but the removed array is never successfully added with any elements.

binarykitchen commented 8 years ago

ooookay, during my investigations i decided to change the api a bit and thus have published a newer version. also comes with some internal changes and with more unit tests. not really a rewrite, rather were fixing things that weren't logical.

@duanmao feel free to check out v1.0 but beware it comes with some breaking changes. would be great to have your feedback if that solved the above issue.