Skip to content

Commit

Permalink
Attempt to fix a "directory not empty" error on EFS in create_zip_file()
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Dolski committed Mar 5, 2024
1 parent c771c15 commit c20011a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/bitstream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def self.create_zip_file(bitstreams:,
task&.update!(indeterminate: false,
started_at: Time.now,
status_text: status_text)
Dir.mktmpdir do |tmpdir|
# We should be able to use a block with mktmpdir, but when using an EFS
# filesystem, we get an error about "directory not empty".
tmpdir = Dir.mktmpdir
begin
bitstreams.each_with_index do |bs, index|
tmpfile = bs.download_to_temp_file
FileUtils.mv(tmpfile.path, File.join(tmpdir, bs.filename))
Expand All @@ -263,6 +266,8 @@ def self.create_zip_file(bitstreams:,
ObjectStore.instance.put_object(key: dest_key,
file: file)
end
ensure
FileUtils.rm_rf(tmpdir)
end
end

Expand Down

0 comments on commit c20011a

Please sign in to comment.