Use stat() instead of opendir() for checking existence of a dir in sftpHelpers #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Original problem:
opendir()
fails if given path doesn't have read permissions forthe current user (permissions 0xx).
I'm working with a hosted environment and can't naturally access the root folder. Since the helper function checks existence of directories starting from the root ('/') via trying to open each dir, using sftp with
createDirectories=true
failed for me. Usingstat()
instead ofopendir()
seems to solve the problem, to me it feels like a better way for checking whether a dir exists or not. However, please note that I'm not 100% sure if there were something else behind the way how this helper function is implemented, thus review & testing welcome.To clarify, the failing scenario with current version can be created as follows:
createDirectories=true