FIX: Use a tmp file in UploadRecovery for local store.

This commit is contained in:
Guo Xiang Tan 2018-09-19 15:46:23 +08:00
parent e0e6dae6a7
commit 293cf600f0

View File

@ -90,10 +90,12 @@ class UploadRecovery
@paths.each do |path|
if path =~ /#{sha1}/
begin
file = File.open(path, "r")
create_upload(file, File.basename(path), post)
tmp = Tempfile.new
tmp.write(File.read(path))
tmp.rewind
create_upload(tmp, File.basename(path), post)
ensure
file&.close
tmp&.close
end
end
end