FIX: Enforce proper max for clean_orphan_uploads_grace_period_hours (#25235)

* FIX: Enforce proper max for clean_orphan_uploads_grace_period_hours

* Cast

* Set clean_orphan_uploads_grace_period_hours to max allowed
This commit is contained in:
Natalie Tay 2024-01-15 10:32:07 +08:00 committed by GitHub
parent 830ca2877d
commit 9bc78625af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -1488,7 +1488,9 @@ files:
regex: '\A((https?:\/\/.+)(\|https?:\/\/.+[|$])*)?\z'
create_thumbnails: true
clean_up_uploads: true
clean_orphan_uploads_grace_period_hours: 48
clean_orphan_uploads_grace_period_hours:
default: 48
max: 168
purge_deleted_uploads_grace_period_days:
default: 30
max: 36500

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
class SetMaxCleanOrphanUploadsGracePeriodHours < ActiveRecord::Migration[7.0]
def up
DB.exec <<~SQL
UPDATE site_settings SET value = '168' WHERE name ='clean_orphan_uploads_grace_period_hours' and value::int > 168;
SQL
end
def down
raise ActiveRecord::IrreversibleMigration.new
end
end

View File

@ -84,7 +84,7 @@ class ImportScripts::Base
clean_up_inactive_users_after_days: 0,
clean_up_unused_staged_users_after_days: 0,
clean_up_uploads: false,
clean_orphan_uploads_grace_period_hours: 1800,
clean_orphan_uploads_grace_period_hours: 168,
}
end