summaryrefslogtreecommitdiff
path: root/app/models/appearance.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-01-23 10:28:26 -0800
committerStan Hu <stanhu@gmail.com>2019-01-23 11:18:00 -0800
commit19f9d998700592be0d40d6727d6e990ef39ada68 (patch)
tree814fa74cc9aaf5e457dcf3ed291dd0515d2f0700 /app/models/appearance.rb
parent768475bd78420b6ca023c1322bc13c336d688056 (diff)
downloadgitlab-ce-19f9d998700592be0d40d6727d6e990ef39ada68.tar.gz
Fix 500 errors with legacy appearance logos
Prior to GitLab 9.0, attachments were not tracked the `uploads` table, so it was possible that the appearance logos were just stored in the database as a string and mounted via CarrierWave. https://gitlab.com/gitlab-org/gitlab-ce/issues/29240 implemented in GitLab 10.3 was supposed to cover populating the `uploads` table for all attachments, including all the logos from appearances. However, it's possible that didn't work for logos or the `uploads` entry was orphaned. GitLab instances that had a customized logo with no associated `uploads` entry would see Error 500s. The only way to fix this is to delete the `logo` column from the `appearances` table and re-upload the attachment. This change makes things more robust by falling back to the original behavior if the upload is not available. This is a CE backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9277. Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/9357
Diffstat (limited to 'app/models/appearance.rb')
-rw-r--r--app/models/appearance.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/appearance.rb b/app/models/appearance.rb
index e114c435b67..ff1ecfda684 100644
--- a/app/models/appearance.rb
+++ b/app/models/appearance.rb
@@ -44,7 +44,11 @@ class Appearance < ActiveRecord::Base
private
def logo_system_path(logo, mount_type)
- return unless logo&.upload
+ # Legacy attachments may not have have an associated Upload record,
+ # so fallback to the AttachmentUploader#url if this is the
+ # case. AttachmentUploader#path doesn't work because for a local
+ # file, this is an absolute path to the file.
+ return logo&.url unless logo&.upload
# If we're using a CDN, we need to use the full URL
asset_host = ActionController::Base.asset_host