diff --git a/app/jobs/scheduled/clean_up_uploads.rb b/app/jobs/scheduled/clean_up_uploads.rb index e23a520521d..3c4f37cc609 100644 --- a/app/jobs/scheduled/clean_up_uploads.rb +++ b/app/jobs/scheduled/clean_up_uploads.rb @@ -48,7 +48,7 @@ module Jobs .where("uploads.created_at < ?", grace_period.hour.ago) .joins(<<~SQL) LEFT JOIN site_settings ss - ON ss.value::integer = uploads.id + ON NULLIF(ss.value, '')::integer = uploads.id AND ss.data_type = #{SiteSettings::TypeSupervisor.types[:upload].to_i} SQL .joins("LEFT JOIN post_uploads pu ON pu.upload_id = uploads.id") diff --git a/spec/jobs/clean_up_uploads_spec.rb b/spec/jobs/clean_up_uploads_spec.rb index b8957b683ba..fe0aa1c5504 100644 --- a/spec/jobs/clean_up_uploads_spec.rb +++ b/spec/jobs/clean_up_uploads_spec.rb @@ -48,6 +48,7 @@ describe Jobs::CleanUpUploads do begin original_provider = SiteSetting.provider SiteSetting.provider = SiteSettings::DbProvider.new(SiteSetting) + SiteSetting.clean_orphan_uploads_grace_period_hours = 1 logo_upload = fabricate_upload logo_small_upload = fabricate_upload @@ -85,6 +86,11 @@ describe Jobs::CleanUpUploads do favicon_upload, apple_touch_icon_upload ].each { |record| expect(Upload.exists?(id: record.id)).to eq(true) } + + fabricate_upload + SiteSetting.opengraph_image = '' + + Jobs::CleanUpUploads.new.execute(nil) ensure SiteSetting.delete_all SiteSetting.provider = original_provider