2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-09-13 04:08:15 -04:00
|
|
|
module Jobs
|
2019-10-02 00:01:53 -04:00
|
|
|
class PostUploadsRecovery < ::Jobs::Onceoff
|
2018-09-13 04:08:15 -04:00
|
|
|
MIN_PERIOD = 30
|
|
|
|
MAX_PERIOD = 120
|
|
|
|
|
|
|
|
def execute_onceoff(args)
|
|
|
|
UploadRecovery.new.recover(Post.where(
|
|
|
|
"baked_at >= ?",
|
|
|
|
grace_period.days.ago
|
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
def grace_period
|
|
|
|
SiteSetting.purge_deleted_uploads_grace_period_days.clamp(
|
|
|
|
MIN_PERIOD,
|
|
|
|
MAX_PERIOD
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|