Merge pull request #4532 from reitermarkus/directory-permissions
Fix directory permissions when unpacking.
This commit is contained in:
commit
45f6cc5bd0
@ -90,6 +90,21 @@ describe DirectoryUnpackStrategy do
|
||||
strategy.extract(to: unpack_dir)
|
||||
expect(unpack_dir/"symlink").to be_a_symlink
|
||||
end
|
||||
|
||||
it "preserves permissions of contained files" do
|
||||
FileUtils.chmod 0644, path/"file"
|
||||
|
||||
strategy.extract(to: unpack_dir)
|
||||
expect((unpack_dir/"file").stat.mode & 0777).to eq 0644
|
||||
end
|
||||
|
||||
it "preserves the permissions of the destination directory" do
|
||||
FileUtils.chmod 0700, path
|
||||
FileUtils.chmod 0755, unpack_dir
|
||||
|
||||
strategy.extract(to: unpack_dir)
|
||||
expect(unpack_dir.stat.mode & 0777).to eq 0755
|
||||
end
|
||||
end
|
||||
|
||||
describe UncompressedUnpackStrategy do
|
||||
|
||||
@ -96,7 +96,9 @@ class DirectoryUnpackStrategy < UnpackStrategy
|
||||
private
|
||||
|
||||
def extract_to_dir(unpack_dir, basename:, verbose:)
|
||||
FileUtils.cp_r File.join(path, "."), unpack_dir, preserve: true, verbose: verbose
|
||||
path.children.each do |child|
|
||||
FileUtils.copy_entry child, unpack_dir/child.basename, true, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user