Merge pull request #3700 from evazion/fix-3659

Fix uploads getting stuck in 'processing' state (fix #3659)
This commit is contained in:
Albert Yi
2018-05-07 17:36:03 -07:00
committed by GitHub
3 changed files with 24 additions and 75 deletions

View File

@@ -94,7 +94,7 @@ module Downloads
else
raise Error.new("HTTP error code: #{res.code} #{res.message}")
end
rescue Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EIO, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, IOError => x
rescue Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EIO, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Timeout::Error, IOError => x
tries += 1
if tries < 3
retry

View File

@@ -165,25 +165,11 @@ class Upload < ApplicationRecord
end
def process!(force = false)
@tries ||= 0
return if !force && status =~ /processing|completed|error/
process_upload
post = create_post_from_upload
rescue Timeout::Error, Net::HTTP::Persistent::Error => x
if @tries > 3
update_attributes(:status => "error: #{x.class} - #{x.message}", :backtrace => x.backtrace.join("\n"))
else
@tries += 1
retry
end
nil
rescue Exception => x
update_attributes(:status => "error: #{x.class} - #{x.message}", :backtrace => x.backtrace.join("\n"))
nil
ensure
file.try(:close!)
end