From 02e4fb2e06f424c16ab25ea294a4af6490a5f7e3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 22 Mar 2016 21:05:23 +0100 Subject: Only re-download avatar if URL changed (fix #19) --- app/models/account.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/models/account.rb') diff --git a/app/models/account.rb b/app/models/account.rb index 06f858c7c..c686a47ed 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -5,7 +5,6 @@ class Account < ActiveRecord::Base validates :username, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?' # Avatar upload - attr_reader :avatar_remote_url has_attached_file :avatar, styles: { large: '300x300#', medium: '96x96#', small: '48x48#' }, default_url: 'avatars/missing.png' validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/ @@ -91,8 +90,11 @@ class Account < ActiveRecord::Base end def avatar_remote_url=(url) - self.avatar = URI.parse(url) - @avatar_remote_url = url + unless self[:avatar_remote_url] == url + self.avatar = URI.parse(url) + end + + self[:avatar_remote_url] = url end def to_param -- cgit