Ruby on rails RubyZip失败-关闭流

Ruby on rails RubyZip失败-关闭流,ruby-on-rails,ruby-on-rails-3,chef-infra,chef-recipe,rubyzip,Ruby On Rails,Ruby On Rails 3,Chef Infra,Chef Recipe,Rubyzip,我有一本包含以下ruby代码的厨师烹饪书: class Chef::Recipe::Helpers def self.is_config?(filename) ['.lua', '.conf'].include?(File.extname(filename)) end def self.out_filename(filename) File.extname(filename) == '.conf' ? 'nginx.conf' : filename end

我有一本包含以下ruby代码的厨师烹饪书:

class Chef::Recipe::Helpers
  def self.is_config?(filename)
    ['.lua', '.conf'].include?(File.extname(filename))
  end

  def self.out_filename(filename)
    File.extname(filename) == '.conf' ? 'nginx.conf' : filename
  end

  def self.unzip(data, dest_dir)
    ::Zip::File.open_buffer(data) do |fzip|
      fzip.each do |entry|
        next unless is_config?(entry.name)
        content = fzip.read(entry)
        filename = out_filename(entry.name)
        path = File.join(dest_dir, filename)
        File.write(path, content)
      end
    end
  end

  def self.fetch_from_url(url, dest_dir)
    response = HTTPClient.get(url, follows_redirect: true)
    if response.status == 200
      unzip(response.body, dest_dir)
    else
      raise 'Could not fetch files from 3scale'
    end
  end
end
我在一个工件存储库中有一个压缩文件,该文件被压缩并上传,我为该代码提供了接收的端点:

ruby_block 'fetch configuration files from a URL' do
  block do
    Helpers.fetch_from_url(node['3scale']['config-url'], version_dir)
  end
  action :run
end
这使用了文章中提到的helper函数,但是当我运行它时,我得到了以下错误:

 * ruby_block[fetch configuration files from a URL] action run
================================================================================
Error executing action `run` on resource 'ruby_block[fetch configuration files from a URL]'
================================================================================


IOError
-------
closed stream


Cookbook Trace:
---------------
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:23:in `block (2 levels) in unzip'
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:21:in `block in unzip'
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:20:in `unzip'
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:34:in `fetch_from_url'
/var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb:79:in `block (2 levels) in from_file'


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb

 77:   ruby_block 'fetch configuration files from a URL' do
 78:     block do
 79:       Helpers.fetch_from_url(node['3scale']['config-url'], version_dir)
 80:     end
 81:     action :run
 82:   end
 83: elsif mode == 'local'



Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb:77:in `from_file'

ruby_block("fetch configuration files from a URL") do
  action [:run]
  retries 0
  retry_delay 2
  block_name "fetch configuration files from a URL"
  cookbook_name "dj-chef-3scale"
  recipe_name "default"
  block #<Proc:0x0000000420e230@/var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb:78>
end
*ruby_block[从URL获取配置文件]操作运行
================================================================================
执行操作“在资源上运行”ruby_块[从URL获取配置文件]时出错
================================================================================
IOError
-------
闭流
食谱跟踪:
---------------
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:23:in`block(2层)in unzip'
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:21:in'block in unzip'
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default_helper.rb:20:in'unzip'
/var/chef/cache/cookbooks/dj-chef-3scale/libraries/default\u helper.rb:34:in'fetch\u from\u url'
/var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb:79:from_文件中的“块(2级)”中
资源声明:
---------------------
#在/var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb中
77:ruby_block“从URL获取配置文件”do
78:block do
79:Helpers.fetch_from_url(节点['3scale']['config-url'],版本目录)
80:完
81:操作:运行
82:完
83:elsif模式==“本地”
汇编资源:
------------------
#在/var/chef/cache/cookbooks/dj-chef-3scale/recipes/default.rb:77:in“from_文件”中声明
ruby_block(“从URL获取配置文件”)可以
动作[:运行]
重试0次
重试\u延迟2
block_name“从URL获取配置文件”
食谱名称“dj-chef-3scale”
配方名称“默认”
挡块#
结束
不知道为什么我会在这里“闭关自守”