what-is-quality / aws-codedeploy-agent

Host Agent for AWS CodeDeploy
https://aws.amazon.com/codedeploy
Apache License 2.0
2 stars 0 forks source link

Ignore non-empty directories in cleanup file #9

Open spilist opened 5 years ago

spilist commented 5 years ago

This closes aws#185.

Description of changes

When installing ruby in ubuntu 18.04, ruby version 2.5.x is installed by default.

Before ruby 2.5(i.e., 2.4.3), FileUtils.rmdir silently fails when the target directory is not empty, so the non-empty directories in cleanup file are not removed.

But the implementation of FileUtils.rmdir is changed in ruby 2.5 so that it doesn’t rescue from Errno::ENOTEMPTY any more, which generates failures in deployment.

This PR adds a rescue from Errno::ENOTEMPTY, thus non-empty directories in cleanup file are not removed for ruby 2.5 and forward, and the deployment does not fail.


Note: There are two other exceptions(Errno::EEXIST, Errno::ENOENT) that have been rescued before ruby 2.5. We don't rescue them because:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.