fix the problem that when upload failed if will lead to not upload
success furthor more and let show description tag can also work for image
This commit is contained in:
parent
b84c4af63a
commit
d82207aa68
|
@ -473,33 +473,34 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
|
||||
def upload_process
|
||||
if AlbumUnprocess.first.upload_success
|
||||
album_unprocess = AlbumUnprocess.all
|
||||
count = album_unprocess.count
|
||||
Thread.new do
|
||||
begin
|
||||
album_unprocess.each_with_index do |un_image,i|
|
||||
album = AlbumImage.all.select{|value| value.id.to_s == un_image.image_id.to_s}[0]
|
||||
album.file = un_image.save_var
|
||||
album.save!
|
||||
file = un_image.save_var.tempfile
|
||||
file.close
|
||||
File.delete file.path
|
||||
un_image.delete
|
||||
variable = AlbumVariable.first
|
||||
album_unprocess = Array(AlbumUnprocess.all)
|
||||
count = album_unprocess.count
|
||||
Thread.new do
|
||||
album_unprocess.each_with_index do |un_image,i|
|
||||
begin
|
||||
album = AlbumImage.all.select{|value| value.id.to_s == un_image.image_id.to_s}[0]
|
||||
album.file = un_image.save_var
|
||||
album.save!
|
||||
file = un_image.save_var.tempfile
|
||||
file.close
|
||||
File.delete file.path
|
||||
un_image.delete
|
||||
variable = AlbumVariable.first
|
||||
variable.progress_filename = album[:file]
|
||||
variable.progress_percent = ((i+1)*100.0/count).floor.to_s + '%'
|
||||
variable.save!
|
||||
end
|
||||
rescue => e
|
||||
puts ['err',e.inspect]
|
||||
end
|
||||
variable = AlbumVariable.first
|
||||
variable.finish = true
|
||||
variable.save!
|
||||
rescue => e
|
||||
puts ['err',un_image.inspect,e.inspect]
|
||||
un_image.destroy
|
||||
end
|
||||
end
|
||||
album_temp = AlbumUnprocess.first
|
||||
album_temp.upload_success = false
|
||||
album_temp.save!
|
||||
variable = AlbumVariable.first
|
||||
variable.finish = true
|
||||
variable.save!
|
||||
end
|
||||
album_temp = AlbumUnprocess.first
|
||||
album_temp.upload_success = false
|
||||
album_temp.save!
|
||||
end
|
||||
end
|
||||
def start_upload_process
|
||||
|
|
|
@ -63,7 +63,7 @@ class GalleriesController < ApplicationController
|
|||
images = album.album_images.asc(:order).collect do |a|
|
||||
alt_text = (a.description.nil? || a.description == "" ? "gallery image" : a.description)
|
||||
{
|
||||
"image-description" => a.description,
|
||||
"image-description" => (flag ? a.description : ''),
|
||||
"alt_title" => alt_text,
|
||||
"link_to_show" => "/xhr/galleries/theater/" + a.id.to_s,
|
||||
"thumb-src" => a.file.thumb.url
|
||||
|
|
Loading…
Reference in New Issue