Promise/Async support - #13
Conversation
… always use de mtime. ctime is used when the permissions file changes, but mtime, when the content file is changed.
mtime instead of ctime
…le operation. The returned Json will only include files deleted. Tests added too.
…tation Adding an option to limit the number of files to be deleted at a single operation
Update README.md
…tation Adding an option to delete by prefix. Tests added too.
binarykitchen
commented
Feb 13, 2018
thanks for your efforts - a couple of problems with your commits:
|
d0b1010r
commented
Feb 13, 2018
I see. Well I can't think of any maintainable way to do these complicated checks with callbacks (as you mentioned) - at the same time I can't envision how it should work with streams / and or events. Perhaps you can share some ideas? I work mostly nowadays with async/await and really like it, it's just so much more readable and logic then all these callbacks (or even promises). The other points:
Seems to be that the files are not old enough in these cases and thus not deleted. It would help to change the check from
|
binarykitchen
commented
Feb 14, 2018
great, looking much better. we're close. about the 0.0005 ... can you change it to a constant at top of test and try to increment it slowly until all test pass. very curious here. dont change to |
binarykitchen
commented
Feb 14, 2018
and yes, don't forget documentation ;) |
d0b1010r
commented
Feb 15, 2018
I think the problem with the 0.0005s check is that it's already higher than the available precision. Or am I overlooking something? From my example: current and modification time is already exactly the same number. Might work to switch to |
binarykitchen
commented
Feb 15, 2018
or it is because we have different CPU speeds? what's your CPU? |
d0b1010r
commented
Feb 16, 2018
It's a 2,6 GHz Intel Core i5 / MBP from 2014 with 10.13.3 |
binarykitchen
commented
Feb 18, 2018
okay your machine is faster than mine, although tests pass here. are you on mac os? |
d0b1010r
commented
Feb 19, 2018
via email
Yes, I am on mac os x. I think it's something with the speed as well. My machine "is too" fast in a way, because the files are not old enough to be older than 0.0005s. Thus a setTimeout of 1ms in the test would ensure that the files are old enough to be watched by the module. |
binarykitchen
commented
Feb 19, 2018
ok, understand. in that case change increase slightly, maybe to 1ms or more until all tests pass. |
binarykitchen
commented
Mar 6, 2018
@davidlanger you still alive? |
d0b1010r
commented
Mar 7, 2018
Yepp, but was on vacation the last two weeks. Will continue as fast as possible. But you wrote to "increase slightly, maybe to 1ms or more". But this won't help the problem, as the problem is that the files are not old enough. The only way to make this check work, is to add timeout, as the problem is that on my computer the files are never old enough to be deleted if the code is run right after the initialization. Illustration:
The time between 1 and 2 is less than the precision available (which is only in milliseconds). 0.0005s is less than a millisecond. With set Timeout:
Now all the newly created files are old enough. |
binarykitchen
commented
Mar 7, 2018
oh i see, sorry - in that case add the timeout then |
binarykitchen
commented
Apr 10, 2018
@davidlanger hello? |
binarykitchen
commented
Apr 26, 2018
@davidlanger you still alive? |
Hibrix-net
commented
Apr 9, 2021
Hello, Cheers, |
binarykitchen
commented
Apr 11, 2021
@Hibrix-net sorry no time and needs rebasing |
binarykitchen
commented
Sep 20, 2023
@mgerylrm thanks for your approval, yet merge conflicts should be resolved first. |
5beec34 to
2059906Compare
Hi, tried my take at adding async support. This requires node 8 with async/await because this allows the code to be really close. The only test I needed to change (apart from the .then) was adding setTimeout with 1 ms for the 0.0005 tests.
What do you think?