DEV: Don't copy file when trying to recover missing uploads.

DEV: Don’t copy file when trying to recover missing uploads.

diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index a0be9c7..38d4b28 100644
--- a/lib/tasks/posts.rake
+++ b/lib/tasks/posts.rake
@@ -434,11 +434,7 @@ def missing_uploads
     end
 
     if file_path.present?
-      tmp = Tempfile.new
-      tmp.write(File.read(file_path))
-      tmp.rewind
-
-      if upload = UploadCreator.new(tmp, File.basename(path)).create_for(Discourse.system_user.id)
+      if upload = UploadCreator.new(File.open(file_path), File.basename(path)).create_for(Discourse.system_user.id)
         upload_id = upload.id
         DbHelper.remap(UrlHelper.absolute(src), upload.url)
 
@@ -451,8 +447,6 @@ def missing_uploads
           post.rebake!
         end
       end
-
-      FileUtils.rm(tmp, force: true)
     else
       old_scheme_upload_count += 1
     end

GitHub sha: f3c13d80

1 Like