OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Avoid running oauth cleanup job after every authentication (#9241)
Oliver Güntherfa3481523bf0
diff --git a/app/models/attachment.rb b/app/models/attachment.rbindex b2b81891588..9d6570d9069 100644--- a/app/models/attachment.rb+++ b/app/models/attachment.rb@@ -53,9 +53,6 @@ class Attachment < ApplicationRecordafter_commit :extract_fulltext, on: :create- after_create :schedule_cleanup_uncontainered_job,- unless: :containered?-### Returns an URL if the attachment is stored in an external (fog) attachment storage# or nil otherwise.@@ -292,10 +289,6 @@ class Attachment < ApplicationRecordprivate- def schedule_cleanup_uncontainered_job- Attachments::CleanupUncontaineredJob.perform_later- end-def filesize_below_allowed_maximumif filesize > Setting.attachment_max_size.to_i.kilobyteserrors.add(:file, :file_too_large, count: Setting.attachment_max_size.to_i.kilobytes)diff --git a/app/workers/attachments/cleanup_uncontainered_job.rb b/app/workers/attachments/cleanup_uncontainered_job.rbindex b3886639284..415273dfdd3 100644--- a/app/workers/attachments/cleanup_uncontainered_job.rb+++ b/app/workers/attachments/cleanup_uncontainered_job.rb@@ -28,9 +28,12 @@# See docs/COPYRIGHT.rdoc for more details.#++-class Attachments::CleanupUncontaineredJob < ApplicationJob+class Attachments::CleanupUncontaineredJob < ::Cron::CronJobqueue_with_priority :low+ # runs at 10:03 pm+ self.cron_expression = '03 22 * * *'+def performAttachment.where(container: nil)diff --git a/app/workers/oauth/cleanup_job.rb b/app/workers/oauth/cleanup_job.rbindex 47cef9f8cc4..50675837616 100644--- a/app/workers/oauth/cleanup_job.rb+++ b/app/workers/oauth/cleanup_job.rb@@ -29,9 +29,13 @@#++module OAuth- class CleanupJob < ::ApplicationJob+ class CleanupJob < ::Cron::CronJobinclude ::RakeJob+ # runs at 1:52 nightly+ self.cron_expression = '52 1 * * *'++queue_with_priority :lowdef performdiff --git a/config/initializers/cronjobs.rb b/config/initializers/cronjobs.rbindex 00e14d88fcc..116d397a2b3 100644--- a/config/initializers/cronjobs.rb+++ b/config/initializers/cronjobs.rb@@ -4,6 +4,8 @@ OpenProject::Application.configure do |application|application.config.to_prepare do::Cron::CronJob.register! ::Cron::ClearOldSessionsJob,::Cron::ClearTmpCacheJob,- ::Cron::ClearUploadedFilesJob+ ::Cron::ClearUploadedFilesJob,+ ::OAuth::CleanupJob,+ ::Attachments::CleanupUncontaineredJobendenddiff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rbindex 7c8bd6f3537..12819f09402 100644--- a/config/initializers/doorkeeper.rb+++ b/config/initializers/doorkeeper.rb@@ -183,10 +183,6 @@ Doorkeeper.configure do# Rails.logger.info(params.inspect)# end#- after_successful_authorization do |_controller|- # Schedule a cleanup job to clean out over-TTL tokens and grants- ::OAuth::CleanupJob.perform_later- end# Under some circumstances you might want to have applications auto-approved,# so that the user skips the authorization step.diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rbindex 5959c406409..9d9d49611fa 100644--- a/spec/models/attachment_spec.rb+++ b/spec/models/attachment_spec.rb@@ -174,21 +174,6 @@ describe Attachment, type: :model doexpect(attachment.digest).to eql Digest::MD5.file(file.path).hexdigestend-- it 'adds no cleanup job' do- expect(Attachments::CleanupUncontaineredJob).not_to receive(:perform_later)-- attachment.save!- end-- context 'with an unclaimed attachment' do- let(:container) { nil }-- it 'adds a cleanup job' do- expect(Attachments::CleanupUncontaineredJob).to receive(:perform_later)- attachment.save!- end- endenddescribe 'two attachments with same file name' do