镜像变动

dev_daiao
daiao 5 years ago
parent 240606e7b0
commit 41d8e5032a

@ -385,10 +385,13 @@ class ShixunsController < ApplicationController
logger.info("##########new_mirror_id: #{old_mirror_ids}")
logger.info("##########mirror_ids: #{mirror_ids}")
# 服务配置方面
service_params = service_config_params[:shixun_service_configs]
service_create_params = service_config_params[:shixun_service_configs]
.select{|config| !old_mirror_ids.include?(config[:mirror_repository_id]) &&
MirrorRepository.find(config[:mirror_repository_id]).name.present?}
logger.info("#########service_params: #{service_params}")
service_update_params = service_config_params[:shixun_service_configs]
.select{|config| old_mirror_ids.include?(config[:mirror_repository_id])}
logger.info("#########service_create_params: #{service_create_params}")
logger.info("#########service_update_params: #{service_update_params}")
begin
ActiveRecord::Base.transaction do
@shixun.update_attributes(shixun_params)
@ -398,7 +401,11 @@ class ShixunsController < ApplicationController
@shixun.shixun_mirror_repositories.create!(new_mirror_id)
# 镜像变动要更换服务配置
@shixun.shixun_service_configs.where.not(mirror_repository_id: old_mirror_ids).destroy_all
@shixun.shixun_mirror_repositories.create!(service_params)
@shixun.shixun_mirror_repositories.create!(service_create_params)
service_update_params&.map do |service|
smr = @shixun.shixun_mirror_repositories.find_by(mirror_repository_id: service[:mirror_repository_id])
smr.update_attributes(service)
end
# 添加第二仓库(管理员权限)
if current_user.admin_or_business?
if params[:is_secret_repository]

Loading…
Cancel
Save