You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
692 B

  1. # frozen_string_literal: true
  2. class Settings::ExportsController < Settings::BaseController
  3. include Authorization
  4. skip_before_action :require_functional!
  5. def show
  6. @export = Export.new(current_account)
  7. @backups = current_user.backups
  8. end
  9. def create
  10. backup = nil
  11. RedisLock.acquire(lock_options) do |lock|
  12. if lock.acquired?
  13. authorize :backup, :create?
  14. backup = current_user.backups.create!
  15. else
  16. raise Mastodon::RaceConditionError
  17. end
  18. end
  19. BackupWorker.perform_async(backup.id)
  20. redirect_to settings_export_path
  21. end
  22. def lock_options
  23. { redis: Redis.current, key: "backup:#{current_user.id}" }
  24. end
  25. end