Skip to content

Commit f3f033c

Browse files
Mike SpertusAlena Kastsiukavets
authored andcommitted
Only strip leading directory if it contains an appspec
cr https://code.amazon.com/reviews/CR-26148300
1 parent 677db19 commit f3f033c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/instance_agent/plugins/codedeploy/command_executor.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,11 @@ def unpack_bundle(cmd, bundle_file, deployment_spec)
401401
archive_root_files = Dir.entries(dst)
402402
archive_root_files.delete_if { |name| name == '.' || name == '..' }
403403

404-
# If the top level of the archive is a directory, strip that before giving up
405-
if ((archive_root_files.size == 1) && File.directory?(File.join(dst, archive_root_files[0])))
404+
# If the top level of the archive is a directory that contains an appspec,
405+
# strip that before giving up
406+
if ((archive_root_files.size == 1) &&
407+
File.directory?(File.join(dst, archive_root_files[0])) &&
408+
Dir.entries(File.join(dst, archive_root_files[0])).grep(/appspec/i).any?)
406409
log(:info, "Stripping leading directory from archive bundle contents.")
407410
# Move the unpacked files to a temporary location
408411
tmp_dst = File.join(deployment_root_dir(deployment_spec), 'deployment-archive-temp')

0 commit comments

Comments
 (0)