Calling the ZipFileGenerator.write function to create a zip file creates a lock on the files, if the files are used further in the process . The file isn't closed. · Issue #307 · rubyzip/rubyzip · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling the ZipFileGenerator.write function to create a zip file creates a lock on the files, if the files are used further in the process . The file isn't closed.
#307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Scenario:
I have a function that downloads the zipped code from aws s3-bucket. Extracts the zip file in a temp folder and then modifies few files from the extracted zip file and create a zip after modification. Later when I try to delete the temp folder it throws me "The process cannot access the file because it is being used by another process."
(NOTE: everything takes place in the same process meaning in the same function).
After carefully looking the code found in the below code
def writeEntries(entries, path, io)
Uh oh!
There was an error while loading. Please reload this page.
Scenario:
I have a function that downloads the zipped code from aws s3-bucket. Extracts the zip file in a temp folder and then modifies few files from the extracted zip file and create a zip after modification. Later when I try to delete the temp folder it throws me "The process cannot access the file because it is being used by another process."
(NOTE: everything takes place in the same process meaning in the same function).
After carefully looking the code found in the below code
def writeEntries(entries, path, io)
end
In line io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read())}, the file is opened but not closed.
Solution :
So I modified the above line of code as follows:
disk_file = File.open(diskFilePath, "rb")
io.get_output_stream(zipFilePath) { |f|
f.puts(disk_file.read())
}
disk_file.close
and was successfully able to delete the temp folder.
Would be great if the modification can be included in the file.
Thanks,
Zaid
The text was updated successfully, but these errors were encountered: