summaryrefslogtreecommitdiff
path: root/app/models/appearance.rb
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-05-02 18:21:42 +0200
committerJan Provaznik <jprovaznik@gitlab.com>2018-05-16 08:58:07 +0200
commit7da3b2cdd09078984416aa03da108ad0a4a4e477 (patch)
tree5de71e612201909d1a93ec93c19571f9a5984194 /app/models/appearance.rb
parent14507fd18110c6662f56709835a0d68468d7680e (diff)
downloadgitlab-ce-7da3b2cdd09078984416aa03da108ad0a4a4e477.tar.gz
Delete remote uploads
ObjectStore uploader requires presence of associated `uploads` record when deleting the upload file (through the carrierwave's after_commit hook) because we keep info whether file is LOCAL or REMOTE in `upload` object. For this reason we can not destroy uploads as "dependent: :destroy" hook because these would be deleted too soon. Instead we rely on carrierwave's hook to destroy `uploads` in after_commit hook. But in before_destroy hook we still have to delete not-mounted uploads (which don't use carrierwave's destroy hook). This has to be done in before_Destroy instead of after_commit because `FileUpload` requires existence of model's object on destroy action. This is not ideal state of things, in a next step we should investigate how to unify model dependencies so we can use same workflow for all uploads. Related to #45425
Diffstat (limited to 'app/models/appearance.rb')
-rw-r--r--app/models/appearance.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/app/models/appearance.rb b/app/models/appearance.rb
index fb66dd0b766..f3cfc8ccd1e 100644
--- a/app/models/appearance.rb
+++ b/app/models/appearance.rb
@@ -1,4 +1,5 @@
class Appearance < ActiveRecord::Base
+ include WithUploads
include CacheMarkdownField
include AfterCommitQueue
include ObjectStorage::BackgroundMove
@@ -14,8 +15,6 @@ class Appearance < ActiveRecord::Base
mount_uploader :logo, AttachmentUploader
mount_uploader :header_logo, AttachmentUploader
- has_many :uploads, as: :model, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
-
CACHE_KEY = "current_appearance:#{Gitlab::VERSION}".freeze
after_commit :flush_redis_cache