Skip to content

Conversation

ianwsperber
Copy link

Fixed some errors I encountered when using the container class's new uploadDirectory function. My fixes are in DirectorySync.php's execute function.

  1. DirectorySync.php would attempt to fopen files for reading without checking if file is readable. Added a quick check with is_readable()
  2. The $requestBody object was being passed to the $requests array, which prevented garbage collection and prevented the file stream for $requestBody from being closed. When adding many files (~100) this could cause a PHP error due to too many files being open. Cast to string before adding to array instead, allowing files to be closed.

…les for reading. May need want to log problem when encountered.
…tityBody were preventing file streams from closing until entire foreach loop was finished.
@jamiehannaford
Copy link
Contributor

@ianwsperber Hey Ian, I really appreciate this PR. I incorporated all of your good feature changes into a new commit. Although I agree the garbage collection needed to be improved, I went about it a different way by explicitly closing the streams (rather than passing in strings). The EntityBody factory would have converted these strings to a temporary stream anyway, so the problem would have still been there. Regardless, thanks!

@ianwsperber
Copy link
Author

@jamiehannaford Glad to help! I like the way you handled the garbage collection, it's more explicit about what is happening. My team is using this SDK heavily as a part of a part of our build step, keep up the good work! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants