Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-09-04 21:57:13 +0300
committerStan Hu <stanhu@gmail.com>2018-09-04 22:20:58 +0300
commitd4bdcfbf19b594646d597bae5eb6d0c0f7354362 (patch)
treef2e29f5c4b60128ffacd8103ef2867eeefc9b544 /app/models/concerns/avatarable.rb
parent8ff02cf7c43b7f7a2f5ca46aa678cfce67eab39b (diff)
Disable project avatar validation if avatar has not changed
Every time a column in the projects table is changed, the Avatarable concern would validate that the avatar file size was under 200K. This not only delays the database changes, but it also can lead to unrelated failures if the HTTP request fails for some reason. Closes #51053
Diffstat (limited to 'app/models/concerns/avatarable.rb')
-rw-r--r--app/models/concerns/avatarable.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb
index c0233661a9b..0d5311a9985 100644
--- a/app/models/concerns/avatarable.rb
+++ b/app/models/concerns/avatarable.rb
@@ -9,7 +9,7 @@ module Avatarable
include Gitlab::Utils::StrongMemoize
validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? }
- validates :avatar, file_size: { maximum: 200.kilobytes.to_i }
+ validates :avatar, file_size: { maximum: 200.kilobytes.to_i }, if: :avatar_changed?
mount_uploader :avatar, AvatarUploader