TRIVIAL: code formatting

This commit is contained in:
Régis Hanol 2014-06-26 19:50:16 +02:00
parent 6907739a0b
commit c0cd109e9d
4 changed files with 8 additions and 5 deletions

View File

@ -48,9 +48,7 @@ class UserAvatarsController < ApplicationController
return render_dot unless user = User.find_by(username_lower: username.downcase)
size = params[:size].to_i
if size > 1000 || size < 1
return render_dot
end
return render_dot if size > 1000 || size < 1
image = nil
version = params[:version].to_i

View File

@ -603,7 +603,7 @@ class User < ActiveRecord::Base
gravatar_downloaded = avatar.gravatar_upload_id
end
if (!self.uploaded_avatar_id && gravatar_downloaded)
if !self.uploaded_avatar_id && gravatar_downloaded
self.update_column(:uploaded_avatar_id, avatar.gravatar_upload_id)
end

View File

@ -34,7 +34,7 @@ class UserAvatar < ActiveRecord::Base
# skip saving, we are not connected to the net
Rails.logger.warn "Failed to download gravatar, socket error - user id #{ user.id }"
ensure
tempfile.unlink if tempfile
tempfile.close! if tempfile && tempfile.respond_to?(:close!)
end
end

View File

@ -1,19 +1,23 @@
desc "Refresh all avatars (download missing gravatars, refresh system)"
task "avatars:refresh" => :environment do
i = 0
puts "Refreshing avatars"
puts
User.find_each do |user|
user.refresh_avatar
user.user_avatar.update_gravatar!
putc "." if (i += 1) % 10 == 0
end
puts
end
desc "Clean up all avatar thumbnails (use this when the thumbnail algorithm changes)"
task "avatars:clean" => :environment do
i = 0
puts "Cleaning up avatar thumbnails"
puts
@ -24,5 +28,6 @@ task "avatars:clean" => :environment do
optimized_image.destroy!
putc "." if (i += 1) % 10 == 0
end
puts
end