简体   繁体   English

rubyzip在activejob中提取空文件

[英]rubyzip extracts empty file in activejob

I have a function in my activejob that extracts a specific file from a zip file. 我的activejob中有一个从zip文件中提取特定文件的功能。 Following code extracted empty file. 以下代码提取了空文件。

def extract_file(from, name)
  to = get_local_dest(name)

  Zip::File.open(from) do |zip_file|
    entry = zip_file.glob(name).first
    puts entry.get_input_stream.read
    entry.extract(to)
  end

return to

end 结束

I added a debugger and ran following line of code in console then the extracted file was not empty. 我添加了一个调试器,并在控制台中运行了以下代码,然后提取的文件不为空。

entry.extract(to)

Can anyone help me with this issue? 谁能帮我解决这个问题? Why this function is extract empty file when it runs in activejob? 为什么此函数在activejob中运行时会提取空文件?

your code seems to be fine. 您的代码似乎很好。 Please make sure your file is not saving again in code that proceeds. 请确保您的文件不会再次保存在继续执行的代码中。

There are chances that it extracted fine but later in code it was save again in empty form. 有可能它提取得很好,但后来在代码中又以空格式保存了。 This had happened to me in past :) 过去这件事发生在我身上:)

Let me know if this resolved your issue. 让我知道这是否解决了您的问题。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM