Skip to content
Snippets Groups Projects
Unverified Commit e098c37d authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #6141 from chrmoritz/unpackDir

fix copying top level symlinks to folders in directory unpack_strategy
parents 5a63de02 3bb0f8c6
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ describe UnpackStrategy::Directory do
mktmpdir.tap do |path|
FileUtils.touch path/"file"
FileUtils.ln_s "file", path/"symlink"
FileUtils.mkdir path/"folder"
FileUtils.ln_s "folder", path/"folderSymlink"
end
}
......@@ -19,6 +21,11 @@ describe UnpackStrategy::Directory do
expect(unpack_dir/"symlink").to be_a_symlink
end
it "does not follow top level symlinks to directories" do
strategy.extract(to: unpack_dir)
expect(unpack_dir/"folderSymlink").to be_a_symlink
end
it "preserves permissions of contained files" do
FileUtils.chmod 0644, path/"file"
......
......@@ -19,7 +19,8 @@ module UnpackStrategy
def extract_to_dir(unpack_dir, basename:, verbose:)
path.children.each do |child|
system_command! "cp",
args: ["-pR", child.directory? ? "#{child}/." : child, unpack_dir/child.basename],
args: ["-pR", (child.directory? && !child.symlink?) ? "#{child}/." : child,
unpack_dir/child.basename],
verbose: verbose
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment