Fix misc rubocop warnings.
This commit is contained in:
@@ -57,7 +57,7 @@ class APNGInspector
|
||||
# if we did, file is probably maliciously formed
|
||||
# fail gracefully without marking the file as corrupt
|
||||
chunks += 1
|
||||
if chunks > 100000
|
||||
if chunks > 100_000
|
||||
iend_reached = true
|
||||
break
|
||||
end
|
||||
@@ -66,7 +66,8 @@ class APNGInspector
|
||||
file.seek(current_pos + chunk_len + 4, IO::SEEK_SET)
|
||||
end
|
||||
end
|
||||
return iend_reached
|
||||
|
||||
iend_reached
|
||||
end
|
||||
|
||||
def inspect!
|
||||
@@ -105,6 +106,7 @@ class APNGInspector
|
||||
if framedata.nil? || framedata.length != 4
|
||||
return -1
|
||||
end
|
||||
return framedata.unpack1("N".freeze)
|
||||
|
||||
framedata.unpack1("N".freeze)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ module ArtistFinder
|
||||
SITE_BLACKLIST = [
|
||||
"artstation.com/artist", # http://www.artstation.com/artist/serafleur/
|
||||
"www.artstation.com", # http://www.artstation.com/serafleur/
|
||||
%r!cdn[ab]?\.artstation\.com/p/assets/images/images!i, # https://cdna.artstation.com/p/assets/images/images/001/658/068/large/yang-waterkuma-b402.jpg?1450269769
|
||||
%r{cdn[ab]?\.artstation\.com/p/assets/images/images}i, # https://cdna.artstation.com/p/assets/images/images/001/658/068/large/yang-waterkuma-b402.jpg?1450269769
|
||||
"ask.fm", # http://ask.fm/mikuroko_396
|
||||
"bcyimg.com",
|
||||
"bcyimg.com/drawer", # https://img9.bcyimg.com/drawer/32360/post/178vu/46229ec06e8111e79558c1b725ebc9e6.jpg
|
||||
@@ -52,7 +52,7 @@ module ArtistFinder
|
||||
"hentai-foundry.com",
|
||||
"hentai-foundry.com/pictures/user", # http://www.hentai-foundry.com/pictures/user/aaaninja/
|
||||
"hentai-foundry.com/user", # http://www.hentai-foundry.com/user/aaaninja/profile
|
||||
%r!pictures\.hentai-foundry\.com(?:/\w)?!i, # http://pictures.hentai-foundry.com/a/aaaninja/
|
||||
%r{pictures\.hentai-foundry\.com(?:/\w)?}i, # http://pictures.hentai-foundry.com/a/aaaninja/
|
||||
"i.imgur.com", # http://i.imgur.com/Ic9q3.jpg
|
||||
"instagram.com", # http://www.instagram.com/serafleur.art/
|
||||
"iwara.tv",
|
||||
@@ -68,7 +68,7 @@ module ArtistFinder
|
||||
"nicovideo.jp/user", # http://www.nicovideo.jp/user/317609
|
||||
"nicovideo.jp/user/illust", # http://seiga.nicovideo.jp/user/illust/29075429
|
||||
"nijie.info", # http://nijie.info/members.php?id=15235
|
||||
%r!nijie\.info/nijie_picture!i, # http://pic03.nijie.info/nijie_picture/32243_20150609224803_0.png
|
||||
%r{nijie\.info/nijie_picture}i, # http://pic03.nijie.info/nijie_picture/32243_20150609224803_0.png
|
||||
"patreon.com", # http://patreon.com/serafleur
|
||||
"pawoo.net", # https://pawoo.net/@148nasuka
|
||||
"pawoo.net/web/accounts", # https://pawoo.net/web/accounts/228341
|
||||
@@ -120,7 +120,7 @@ module ArtistFinder
|
||||
|
||||
SITE_BLACKLIST_REGEXP = Regexp.union(SITE_BLACKLIST.map do |domain|
|
||||
domain = Regexp.escape(domain) if domain.is_a?(String)
|
||||
%r!\Ahttps?://(?:[a-zA-Z0-9_-]+\.)*#{domain}/\z!i
|
||||
%r{\Ahttps?://(?:[a-zA-Z0-9_-]+\.)*#{domain}/\z}i
|
||||
end)
|
||||
|
||||
def find_artists(url)
|
||||
@@ -128,7 +128,7 @@ module ArtistFinder
|
||||
artists = []
|
||||
|
||||
while artists.empty? && url.size > 10
|
||||
u = url.sub(/\/+$/, "") + "/"
|
||||
u = url.sub(%r{/+$}, "") + "/"
|
||||
u = u.to_escaped_for_sql_like.gsub(/\*/, '%') + '%'
|
||||
artists += Artist.joins(:urls).where(["artists.is_deleted = FALSE AND artist_urls.normalized_url LIKE ? ESCAPE E'\\\\'", u]).limit(10).order("artists.name").all
|
||||
url = File.dirname(url) + "/"
|
||||
|
||||
@@ -148,8 +148,6 @@ class BulkUpdateRequestProcessor
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.is_tag_move_allowed?(antecedent_name, consequent_name)
|
||||
antecedent_tag = Tag.find_by_name(Tag.normalize_name(antecedent_name))
|
||||
consequent_tag = Tag.find_by_name(Tag.normalize_name(consequent_name))
|
||||
|
||||
@@ -16,7 +16,7 @@ module HasBitFlags
|
||||
end
|
||||
|
||||
define_method("#{attribute}=") do |val|
|
||||
if val.to_s =~ /t|1|y/
|
||||
if val.to_s =~ /[t1y]/
|
||||
send("#{field}=", send(field) | bit_flag)
|
||||
else
|
||||
send("#{field}=", send(field) & ~bit_flag)
|
||||
|
||||
@@ -11,8 +11,6 @@ module Mentionable
|
||||
# - user_field
|
||||
def mentionable(options = {})
|
||||
@mentionable_options = options
|
||||
|
||||
message_field = mentionable_option(:message_field)
|
||||
after_save :queue_mention_messages
|
||||
end
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ module Searchable
|
||||
def where_array_count(attr, value)
|
||||
qualified_column = "cardinality(#{qualified_column_for(attr)})"
|
||||
range = PostQueryBuilder.new(nil).parse_range(value, :integer)
|
||||
where_operator("cardinality(#{qualified_column_for(attr)})", *range)
|
||||
where_operator(qualified_column, *range)
|
||||
end
|
||||
|
||||
def search_boolean_attribute(attribute, params)
|
||||
@@ -170,7 +170,7 @@ module Searchable
|
||||
end
|
||||
end
|
||||
|
||||
def search_text_attribute(attr, params, **options)
|
||||
def search_text_attribute(attr, params)
|
||||
if params[attr].present?
|
||||
where(attr => params[attr])
|
||||
elsif params[:"#{attr}_eq"].present?
|
||||
@@ -279,7 +279,8 @@ module Searchable
|
||||
return find_ordered(parse_ids[1])
|
||||
end
|
||||
end
|
||||
return default_order
|
||||
|
||||
default_order
|
||||
end
|
||||
|
||||
def default_order
|
||||
|
||||
@@ -11,7 +11,7 @@ class DText
|
||||
html = DTextRagel.parse(text, **options)
|
||||
html = postprocess(html, *data)
|
||||
html
|
||||
rescue DTextRagel::Error => e
|
||||
rescue DTextRagel::Error
|
||||
""
|
||||
end
|
||||
|
||||
@@ -135,7 +135,7 @@ class DText
|
||||
fragment = Nokogiri::HTML.fragment(html)
|
||||
|
||||
titles = fragment.css("a.dtext-wiki-link").map do |node|
|
||||
title = node["href"][%r!\A/wiki_pages/(.*)\z!i, 1]
|
||||
title = node["href"][%r{\A/wiki_pages/(.*)\z}i, 1]
|
||||
title = CGI.unescape(title)
|
||||
title = WikiPage.normalize_title(title)
|
||||
title
|
||||
@@ -163,7 +163,7 @@ class DText
|
||||
string = string.dup
|
||||
|
||||
string.gsub!(/\s*\[#{tag}\](?!\])\s*/mi, "\n\n[#{tag}]\n\n")
|
||||
string.gsub!(/\s*\[\/#{tag}\]\s*/mi, "\n\n[/#{tag}]\n\n")
|
||||
string.gsub!(%r{\s*\[/#{tag}\]\s*}mi, "\n\n[/#{tag}]\n\n")
|
||||
string.gsub!(/(?:\r?\n){3,}/, "\n\n")
|
||||
string.strip!
|
||||
|
||||
@@ -203,7 +203,7 @@ class DText
|
||||
end
|
||||
end
|
||||
|
||||
text = text.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
|
||||
text.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "")
|
||||
end
|
||||
|
||||
def self.from_html(text, inline: false, &block)
|
||||
|
||||
@@ -17,10 +17,7 @@ class ImageProxy
|
||||
end
|
||||
|
||||
response = HTTParty.get(url, Danbooru.config.httparty_options.deep_merge(headers: {"Referer" => fake_referer_for(url)}))
|
||||
if response.success?
|
||||
return response
|
||||
else
|
||||
raise "HTTP error code: #{response.code} #{response.message}"
|
||||
end
|
||||
raise "HTTP error code: #{response.code} #{response.message}" unless response.success?
|
||||
response
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class IpLookup
|
||||
end
|
||||
|
||||
def info
|
||||
return {} unless api_key.present?
|
||||
return {} if api_key.blank?
|
||||
response = Danbooru::Http.cache(cache_duration).get("https://api.ipregistry.co/#{ip_addr}?key=#{api_key}")
|
||||
return {} if response.status != 200
|
||||
json = response.parse.deep_symbolize_keys.with_indifferent_access
|
||||
|
||||
@@ -42,7 +42,7 @@ class MediaFile::Flash < MediaFile
|
||||
signature = contents[0..2]
|
||||
|
||||
# SWF version
|
||||
version = contents[3].unpack('C').join.to_i
|
||||
_version = contents[3].unpack('C').join.to_i
|
||||
|
||||
# Determine the length of the uncompressed stream
|
||||
length = contents[4..7].unpack('V').join.to_i
|
||||
@@ -50,7 +50,7 @@ class MediaFile::Flash < MediaFile
|
||||
# If we do, in fact, have compression
|
||||
if signature == 'CWS'
|
||||
# Decompress the body of the SWF
|
||||
body = Zlib::Inflate.inflate( contents[8..length] )
|
||||
body = Zlib::Inflate.inflate(contents[8..length])
|
||||
|
||||
# And reconstruct the stream contents to the first 8 bytes (header)
|
||||
# Plus our decompressed body
|
||||
@@ -58,10 +58,10 @@ class MediaFile::Flash < MediaFile
|
||||
end
|
||||
|
||||
# Determine the nbits of our dimensions rectangle
|
||||
nbits = contents.unpack('C'*contents.length)[8] >> 3
|
||||
nbits = contents.unpack('C' * contents.length)[8] >> 3
|
||||
|
||||
# Determine how many bits long this entire RECT structure is
|
||||
rectbits = 5 + nbits * 4 # 5 bits for nbits, as well as nbits * number of fields (4)
|
||||
rectbits = 5 + nbits * 4 # 5 bits for nbits, as well as nbits * number of fields (4)
|
||||
|
||||
# Determine how many bytes rectbits composes (ceil(rectbits/8))
|
||||
rectbytes = (rectbits.to_f / 8).ceil
|
||||
@@ -70,11 +70,11 @@ class MediaFile::Flash < MediaFile
|
||||
rect = contents[8..(8 + rectbytes)].unpack("#{'B8' * rectbytes}").join
|
||||
|
||||
# Read in nbits incremenets starting from 5
|
||||
dimensions = Array.new
|
||||
dimensions = []
|
||||
4.times do |n|
|
||||
s = 5 + (n * nbits) # Calculate our start index
|
||||
e = s + (nbits - 1) # Calculate our end index
|
||||
dimensions[n] = rect[s..e].to_i(2) # Read that range (binary) and convert it to an integer
|
||||
dimensions[n] = rect[s..e].to_i(2) # Read that range (binary) and convert it to an integer
|
||||
end
|
||||
|
||||
# The values we have here are in "twips"
|
||||
|
||||
@@ -106,10 +106,7 @@ module PaginationExtension
|
||||
def total_count
|
||||
@paginator_count ||= unscoped.from(except(:offset, :limit, :order).reorder(nil)).count
|
||||
rescue ActiveRecord::StatementInvalid => e
|
||||
if e.to_s =~ /statement timeout/
|
||||
@paginator_count ||= 1_000_000
|
||||
else
|
||||
raise
|
||||
end
|
||||
raise unless e.to_s =~ /statement timeout/
|
||||
@paginator_count ||= 1_000_000
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,15 +128,15 @@ class PawooApiClient
|
||||
rescue
|
||||
data = {}
|
||||
end
|
||||
return Account.new(data)
|
||||
Account.new(data)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_access_token
|
||||
raise MissingConfigurationError.new("missing pawoo client id") if Danbooru.config.pawoo_client_id.nil?
|
||||
raise MissingConfigurationError.new("missing pawoo client secret") if Danbooru.config.pawoo_client_secret.nil?
|
||||
raise MissingConfigurationError, "missing pawoo client id" if Danbooru.config.pawoo_client_id.nil?
|
||||
raise MissingConfigurationError, "missing pawoo client secret" if Danbooru.config.pawoo_client_secret.nil?
|
||||
|
||||
Cache.get("pawoo-token") do
|
||||
result = client.client_credentials.get_token
|
||||
|
||||
@@ -58,7 +58,7 @@ class PixivWebAgent
|
||||
end
|
||||
|
||||
begin
|
||||
mech.get("https://comic.pixiv.net") do |page|
|
||||
mech.get("https://comic.pixiv.net") do
|
||||
cookie = mech.cookies.select {|x| x.name == COMIC_SESSION_COOKIE_KEY}.first
|
||||
if cookie
|
||||
Cache.put(COMIC_SESSION_CACHE_KEY, cookie.value, 1.week)
|
||||
|
||||
@@ -94,7 +94,7 @@ module PostSets
|
||||
end
|
||||
|
||||
def get_random_posts
|
||||
per_page.times.inject([]) do |all, x|
|
||||
per_page.times.inject([]) do |all, _|
|
||||
all << ::Post.user_tag_match(tag_string).random
|
||||
end.compact.uniq
|
||||
end
|
||||
@@ -104,9 +104,9 @@ module PostSets
|
||||
@post_count = get_post_count
|
||||
|
||||
if is_random?
|
||||
temp = get_random_posts
|
||||
get_random_posts
|
||||
else
|
||||
temp = normalized_query.build.paginate(page, count: post_count, search_count: !post_count.nil?, limit: per_page)
|
||||
normalized_query.build.paginate(page, count: post_count, search_count: !post_count.nil?, limit: per_page)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,10 +7,11 @@ class SpamDetector
|
||||
# if a person receives more than 10 automatic spam reports within a 1 hour
|
||||
# window, automatically ban them forever.
|
||||
AUTOBAN_THRESHOLD = 10
|
||||
AUTOBAN_WINDOW = 1.hours
|
||||
AUTOBAN_DURATION = 999999
|
||||
AUTOBAN_WINDOW = 1.hour
|
||||
AUTOBAN_DURATION = 999_999
|
||||
|
||||
attr_accessor :record, :user, :user_ip, :content, :comment_type
|
||||
|
||||
rakismet_attrs author: proc { user.name },
|
||||
author_email: proc { user.email_address&.address },
|
||||
blog_lang: "en",
|
||||
@@ -84,8 +85,8 @@ class SpamDetector
|
||||
end
|
||||
|
||||
is_spam
|
||||
rescue StandardError => exception
|
||||
DanbooruLogger.log(exception)
|
||||
rescue StandardError => e
|
||||
DanbooruLogger.log(e)
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ class StorageManager::SFTP < StorageManager
|
||||
temp_upload_path = dest_path + "-" + SecureRandom.uuid + ".tmp"
|
||||
dest_backup_path = dest_path + "-" + SecureRandom.uuid + ".bak"
|
||||
|
||||
each_host do |host, sftp|
|
||||
each_host do |_host, sftp|
|
||||
sftp.upload!(file.path, temp_upload_path)
|
||||
sftp.setstat!(temp_upload_path, permissions: DEFAULT_PERMISSIONS)
|
||||
|
||||
@@ -40,7 +40,7 @@ class StorageManager::SFTP < StorageManager
|
||||
end
|
||||
|
||||
def delete(dest_path)
|
||||
each_host do |host, sftp|
|
||||
each_host do |_host, sftp|
|
||||
force { sftp.remove!(dest_path) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,8 +25,7 @@ module TagAutocomplete
|
||||
def search(query)
|
||||
query = Tag.normalize_name(query)
|
||||
|
||||
candidates = count_sort(
|
||||
query,
|
||||
count_sort(
|
||||
search_exact(query, 8) +
|
||||
search_prefix(query, 4) +
|
||||
search_correct(query, 2) +
|
||||
@@ -34,7 +33,7 @@ module TagAutocomplete
|
||||
)
|
||||
end
|
||||
|
||||
def count_sort(query, words)
|
||||
def count_sort(words)
|
||||
words.uniq(&:name).sort_by do |x|
|
||||
x.post_count * x.weight
|
||||
end.reverse.slice(0, LIMIT)
|
||||
|
||||
@@ -4,11 +4,11 @@ module TagRelationshipRetirementService
|
||||
THRESHOLD = 2.years
|
||||
|
||||
def forum_topic_title
|
||||
return "Retired tag aliases & implications"
|
||||
"Retired tag aliases & implications"
|
||||
end
|
||||
|
||||
def forum_topic_body
|
||||
return "This topic deals with tag relationships created two or more years ago that have not been used since. They will be retired. This topic will be updated as an automated system retires expired relationships."
|
||||
"This topic deals with tag relationships created two or more years ago that have not been used since. They will be retired. This topic will be updated as an automated system retires expired relationships."
|
||||
end
|
||||
|
||||
def dry_run
|
||||
@@ -27,7 +27,7 @@ module TagRelationshipRetirementService
|
||||
forum_post = ForumPost.create!(creator: User.system, body: forum_topic_body, topic: topic)
|
||||
end
|
||||
end
|
||||
return topic
|
||||
topic
|
||||
end
|
||||
|
||||
def find_and_retire!
|
||||
@@ -50,16 +50,6 @@ module TagRelationshipRetirementService
|
||||
yield(rel)
|
||||
end
|
||||
end
|
||||
|
||||
# model.active.where("created_at < ?", SMALL_THRESHOLD.ago).find_each do |rel|
|
||||
# if is_underused?(rel.consequent_name)
|
||||
# yield(rel)
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def is_underused?(name)
|
||||
(Tag.find_by_name(name).try(:post_count) || 0) < COUNT_THRESHOLD
|
||||
end
|
||||
|
||||
def is_unused?(name)
|
||||
|
||||
@@ -2,7 +2,7 @@ class UploadLimit
|
||||
extend Memoist
|
||||
|
||||
INITIAL_POINTS = 1000
|
||||
MAXIMUM_POINTS = 10000
|
||||
MAXIMUM_POINTS = 10_000
|
||||
|
||||
attr_reader :user
|
||||
|
||||
@@ -75,7 +75,7 @@ class UploadLimit
|
||||
points += upload_value(points, is_deleted)
|
||||
points = points.clamp(0, MAXIMUM_POINTS)
|
||||
|
||||
#warn "slots: %2d, points: %3d, value: %2d" % [UploadLimit.points_to_level(points) + 5, points, UploadLimit.upload_value(level, is_deleted)]
|
||||
# warn "slots: %2d, points: %3d, value: %2d" % [UploadLimit.points_to_level(points) + 5, points, UploadLimit.upload_value(level, is_deleted)]
|
||||
end
|
||||
|
||||
points
|
||||
|
||||
@@ -15,7 +15,6 @@ class UploadService
|
||||
start!
|
||||
end
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
return
|
||||
end
|
||||
|
||||
def start!
|
||||
@@ -31,8 +30,8 @@ class UploadService
|
||||
|
||||
begin
|
||||
create_post_from_upload(@upload)
|
||||
rescue Exception => x
|
||||
@upload.update(status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n"))
|
||||
rescue Exception => e
|
||||
@upload.update(status: "error: #{e.class} - #{e.message}", backtrace: e.backtrace.join("\n"))
|
||||
end
|
||||
return @upload
|
||||
end
|
||||
@@ -53,16 +52,16 @@ class UploadService
|
||||
|
||||
@upload.save!
|
||||
@post = create_post_from_upload(@upload)
|
||||
return @upload
|
||||
rescue Exception => x
|
||||
@upload.update(status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n"))
|
||||
@upload
|
||||
rescue Exception => e
|
||||
@upload.update(status: "error: #{e.class} - #{e.message}", backtrace: e.backtrace.join("\n"))
|
||||
@upload
|
||||
end
|
||||
end
|
||||
|
||||
def warnings
|
||||
return [] if @post.nil?
|
||||
return @post.warnings.full_messages
|
||||
@post.warnings.full_messages
|
||||
end
|
||||
|
||||
def create_post_from_upload(upload)
|
||||
|
||||
@@ -13,7 +13,7 @@ class UploadService
|
||||
rescue Exception
|
||||
end
|
||||
|
||||
return [upload, remote_size]
|
||||
[upload, remote_size]
|
||||
end
|
||||
|
||||
if file
|
||||
@@ -21,7 +21,7 @@ class UploadService
|
||||
Preprocessor.new(file: file).delayed_start(CurrentUser.id)
|
||||
end
|
||||
|
||||
return [upload]
|
||||
[upload]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,11 +46,9 @@ class UploadService
|
||||
|
||||
def predecessor
|
||||
if md5.present?
|
||||
return Upload.where(status: ["preprocessed", "preprocessing"], md5: md5).first
|
||||
end
|
||||
|
||||
if Utils.is_downloadable?(source)
|
||||
return Upload.where(status: ["preprocessed", "preprocessing"], source: source).first
|
||||
Upload.where(status: ["preprocessed", "preprocessing"], md5: md5).first
|
||||
elsif Utils.is_downloadable?(source)
|
||||
Upload.where(status: ["preprocessed", "preprocessing"], source: source).first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,21 +61,20 @@ class UploadService
|
||||
start!
|
||||
end
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
return
|
||||
end
|
||||
|
||||
def start!
|
||||
if Utils.is_downloadable?(source)
|
||||
if Post.system_tag_match("source:#{canonical_source}").where.not(id: original_post_id).exists?
|
||||
raise ActiveRecord::RecordNotUnique.new("A post with source #{canonical_source} already exists")
|
||||
raise ActiveRecord::RecordNotUnique, "A post with source #{canonical_source} already exists"
|
||||
end
|
||||
|
||||
if Upload.where(source: source, status: "completed").exists?
|
||||
raise ActiveRecord::RecordNotUnique.new("A completed upload with source #{source} already exists")
|
||||
raise ActiveRecord::RecordNotUnique, "A completed upload with source #{source} already exists"
|
||||
end
|
||||
|
||||
if Upload.where(source: source).where("status like ?", "error%").exists?
|
||||
raise ActiveRecord::RecordNotUnique.new("An errored upload with source #{source} already exists")
|
||||
raise ActiveRecord::RecordNotUnique, "An errored upload with source #{source} already exists"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,21 +92,21 @@ class UploadService
|
||||
upload.tag_string = params[:tag_string]
|
||||
upload.status = "preprocessed"
|
||||
upload.save!
|
||||
rescue Exception => x
|
||||
upload.update(file_ext: nil, status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n"))
|
||||
rescue Exception => e
|
||||
upload.update(file_ext: nil, status: "error: #{e.class} - #{e.message}", backtrace: e.backtrace.join("\n"))
|
||||
end
|
||||
|
||||
return upload
|
||||
upload
|
||||
end
|
||||
|
||||
def finish!(upload = nil)
|
||||
pred = upload || self.predecessor
|
||||
pred = upload || predecessor
|
||||
|
||||
# regardless of who initialized the upload, credit should
|
||||
# goto whoever submitted the form
|
||||
pred.initialize_attributes
|
||||
|
||||
pred.attributes = self.params
|
||||
pred.attributes = params
|
||||
|
||||
# if a file was uploaded after the preprocessing occurred,
|
||||
# then process the file and overwrite whatever the preprocessor
|
||||
@@ -118,7 +115,7 @@ class UploadService
|
||||
|
||||
pred.status = "completed"
|
||||
pred.save
|
||||
return pred
|
||||
pred
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ class UploadService
|
||||
end
|
||||
|
||||
def source_strategy(upload)
|
||||
return Sources::Strategies.find(upload.source, upload.referer_url)
|
||||
Sources::Strategies.find(upload.source, upload.referer_url)
|
||||
end
|
||||
|
||||
def find_replacement_url(repl, upload)
|
||||
@@ -78,7 +78,7 @@ class UploadService
|
||||
return source_strategy(upload).canonical_url
|
||||
end
|
||||
|
||||
return upload.source
|
||||
upload.source
|
||||
end
|
||||
|
||||
def process!
|
||||
|
||||
@@ -83,7 +83,7 @@ class UploadService
|
||||
}
|
||||
end
|
||||
|
||||
return file
|
||||
file
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ class UserDeletion
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_reader :user, :password
|
||||
|
||||
validate :validate_deletion
|
||||
|
||||
def initialize(user, password)
|
||||
|
||||
Reference in New Issue
Block a user