2020-06-19 00:07:23 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Repositories
|
|
|
|
class ArchiveRepositoryService < ArchiveRepositoryBaseService
|
|
|
|
def call
|
|
|
|
return self unless valid?
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
@repositories.each do |repository|
|
2020-06-19 15:04:42 +08:00
|
|
|
repository.archive!(@user)
|
2020-06-22 20:57:35 +08:00
|
|
|
|
|
|
|
log_activity(:archive_inventory, repository)
|
2020-06-19 00:07:23 +08:00
|
|
|
end
|
2021-01-08 15:05:05 +08:00
|
|
|
rescue ActiveRecord::RecordInvalid
|
2020-06-19 00:07:23 +08:00
|
|
|
@errors[:archiving_error] = I18n.t('repositories.archive_inventories.unsuccess_flash')
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
end
|
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|