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:
Errno::EEXIST - File exists: it doesn't occur in our use case. (Frankly I have no idea why this rescue is needed from the first time)
Errno::ENOENT - No such file or directory: it doesn't occur since we first check File.exist?(@file_path) before FileUtils.rmdir(@file_path) is executed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
This closes aws#185.
Description of changes
When installing ruby in
ubuntu 18.04
, ruby version2.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 ruby2.5
so that it doesn’t rescue fromErrno::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 ruby2.5
. We don't rescue them because:Errno::EEXIST
- File exists: it doesn't occur in our use case. (Frankly I have no idea why this rescue is needed from the first time)Errno::ENOENT
- No such file or directory: it doesn't occur since we first checkFile.exist?(@file_path)
beforeFileUtils.rmdir(@file_path)
is executed.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.