-
Notifications
You must be signed in to change notification settings - Fork 80
Fix recursion when listing directories #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sftp::scanDirectory() always recursively scans a whole directory tree even if no recursion is wanted. This patch uses scandir instead of the recursive method-call to avoid this.
Can this please be merged? |
@woiwa Thanks for your contribution.
|
@h4cc The only thing I changed is the arrangement of some commands because the original code walks down recursively to check for directories... even if the $recursive argument is set to false. So listing a directory with many subdirectories will last very long, even with $recursive = false. I didn't update any tests - and you're right, providing a test would have been better. But there aren't Testcases for the Sftp-Class in the original code - and I didn't change any functionality. The problem was fixed within a short time, and I thought setting up a brand new test for "Check if scanDirectory() scans recursively even if $recursive is set to false" isn't worth it. :-) The test will be a bit difficult to write, because the original method does the recursion because it hits a loop before processing the $recursive argument - but the return value is correct and the same value as in my patch. And it is difficult (I don't know, maybe impossible) to test the "internals" of scanDirectory() without some bigger changes in the class. (Maybe I am wrong). I will update my fork and look what travis says. I don't have used travis until now, so that's a good opportunity to check it out. :-) |
@h4cc |
Fix recursion when listing directories.
Thanks for your effort. |
Sftp::scanDirectory() always recursively scans a whole directory tree even if no recursion is wanted. This patch uses scandir instead of the recursive method-call to avoid this.
Because this patch uses scandir() there might be the same problems described in an issue and pull request.
This is my first pull request ever, so feel free to point out things I made wrong.