Closed medusalix closed 5 years ago
This way works fine, but I had another idea in mind. If we have ['foo', 'foo/bar', 'foo/baz']
, couldn't we just remove foo/bar
and foo/baz
? As foo
will remove those anyway. I think this would help speed up the deletion process too and reduce the situations where users encounter https://github.com/sindresorhus/trash-cli/issues/9.
@sindresorhus Your proposed solution is actually slower the way I have implemented it 😄. I traverse the whole array for each item to check if there's already a directory above it.
To be honest, I think the operation system is much quicker at moving files to the trash than JS is at de-duplicating an array.
Your proposed solution is actually slower the way I have implemented it
How was that measured? The difference is probably negligible for macOS, but for Linux we actually remove each file using JS, so I think my solution would be more efficient then.
To be honest, I think the operation system is much quicker at moving files to the trash than JS is at de-duplicating an array.
I highly doubt that.
Makes it possible to use the option
glob
with nested directories through sorting the filepaths by their depth before passing them to thetrash
function.Fixes #75