Merge branch 'release/11.2' into dev

pull/9245/head
ulferts 4 years ago
commit 22113a4b65
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 7
      app/models/attachment.rb
  2. 5
      app/workers/attachments/cleanup_uncontainered_job.rb
  3. 6
      app/workers/oauth/cleanup_job.rb
  4. 4
      config/initializers/cronjobs.rb
  5. 4
      config/initializers/doorkeeper.rb
  6. 15
      spec/models/attachment_spec.rb

@ -54,9 +54,6 @@ class Attachment < ApplicationRecord
after_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.
@ -293,10 +290,6 @@ class Attachment < ApplicationRecord
private
def schedule_cleanup_uncontainered_job
Attachments::CleanupUncontaineredJob.perform_later
end
def filesize_below_allowed_maximum
if filesize > Setting.attachment_max_size.to_i.kilobytes
errors.add(:file, :file_too_large, count: Setting.attachment_max_size.to_i.kilobytes)

@ -28,9 +28,12 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
class Attachments::CleanupUncontaineredJob < ApplicationJob
class Attachments::CleanupUncontaineredJob < ::Cron::CronJob
queue_with_priority :low
# runs at 10:03 pm
self.cron_expression = '03 22 * * *'
def perform
Attachment
.where(container: nil)

@ -29,9 +29,13 @@
#++
module OAuth
class CleanupJob < ::ApplicationJob
class CleanupJob < ::Cron::CronJob
include ::RakeJob
# runs at 1:52 nightly
self.cron_expression = '52 1 * * *'
queue_with_priority :low
def perform

@ -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::CleanupUncontaineredJob
end
end

@ -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.

@ -174,21 +174,6 @@ describe Attachment, type: :model do
expect(attachment.digest)
.to eql Digest::MD5.file(file.path).hexdigest
end
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
end
end
describe 'two attachments with same file name' do

Loading…
Cancel
Save