2018-10-22 03:00:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-26 08:10:53 -04:00
|
|
|
# To make a call happen in a new Sidekiq job, add `.async` before the call. For
|
|
|
|
# instance:
|
|
|
|
#
|
|
|
|
# PagesTransfer.new.async.move_namespace(...)
|
|
|
|
#
|
2015-12-18 06:40:34 -05:00
|
|
|
module Gitlab
|
|
|
|
class PagesTransfer < ProjectTransfer
|
2021-02-16 13:09:24 -05:00
|
|
|
METHODS = %w[move_namespace move_project rename_project rename_namespace].freeze
|
2020-08-26 08:10:53 -04:00
|
|
|
|
2021-02-16 13:09:24 -05:00
|
|
|
class Async
|
2020-08-26 08:10:53 -04:00
|
|
|
METHODS.each do |meth|
|
|
|
|
define_method meth do |*args|
|
2021-04-06 08:09:21 -04:00
|
|
|
next unless Settings.pages.local_store.enabled
|
2021-02-16 13:09:24 -05:00
|
|
|
|
2020-08-26 08:10:53 -04:00
|
|
|
PagesTransferWorker.perform_async(meth, args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-16 13:09:24 -05:00
|
|
|
METHODS.each do |meth|
|
|
|
|
define_method meth do |*args|
|
2021-04-06 08:09:21 -04:00
|
|
|
next unless Settings.pages.local_store.enabled
|
2021-02-16 13:09:24 -05:00
|
|
|
|
|
|
|
super(*args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-26 08:10:53 -04:00
|
|
|
def async
|
|
|
|
@async ||= Async.new
|
|
|
|
end
|
|
|
|
|
2015-12-18 06:40:34 -05:00
|
|
|
def root_dir
|
|
|
|
Gitlab.config.pages.path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|