Fix bug that upload multiple files failed.

This commit is contained in:
BoHung Chiu 2022-10-04 18:03:03 +08:00
parent 38cc9fbc8b
commit c30bda01d2
1 changed files with 3 additions and 2 deletions

View File

@ -498,7 +498,7 @@ class Admin::GalleriesController < OrbitAdminController
def upload_process
if AlbumUnprocess.first.upload_success
if (AlbumUnprocess.first.upload_success rescue false)
album_unprocess = Array(AlbumUnprocess.all)
count = album_unprocess.count
Thread.new do
@ -563,6 +563,7 @@ class Admin::GalleriesController < OrbitAdminController
album_unprocess.save_var = file
album_unprocess.save!
ObjectSpace.undefine_finalizer(file.tempfile)
request.set_header(Rack::RACK_TEMPFILES, []) # Avoid Rack::TempfileReaper Middleware to unlink temp files automatically.
end
image.save!
end
@ -572,7 +573,7 @@ class Admin::GalleriesController < OrbitAdminController
def last_image_id
album = Album.find(params[:albumid])
lastimage = album.album_images.last
render :json => {"last_image_id" => lastimage.id.to_s}.to_json
render :json => {"last_image_id" => (lastimage ? lastimage.id.to_s : nil)}.to_json
end
def new_images