From 1f18b1399bbf64d415ae13c91d356044ee7b5d74 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 25 Jul 2019 15:20:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=AE=9E=E8=AE=AD=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 649516a03..cdeca4871 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -20,28 +20,29 @@ class MyshixunsController < ApplicationController unless (current_user.admin? || current_user.id == @myshixun.user_id) tip_exception("403", "") end + begin + ActiveRecord::Base.transaction do + begin + @shixun = Shixun.select(:id, :identifier).find(@myshixun.shixun_id) + @myshixun.destroy - ActiveRecord::Base.transaction do - begin - @shixun = Shixun.select(:id, :identifier).find(@myshixun.shixun_id) - @myshixun.destroy + StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0) - # 刪除版本庫 - begin - GitService.delete_repository(repo_path: @repo_path) + # 实训在申请发布前,是否玩过实训,如果玩过需要更改记录,防止二次重置 + shixun_mod = ShixunModify.where(:shixun_id => @shixun.id, :myshixun_id => @myshixun.id, :status => 1).take + shixun_mod.update_column(:status, 0) if shixun_mod rescue Exception => e - uid_logger_error("版本库删除异常,详情:#{e.message}") + logger.error("######reset_my_game_failed:#{e.message}") + raise("ActiveRecord::RecordInvalid") end - - StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0) - - # 实训在申请发布前,是否玩过实训,如果玩过需要更改记录,防止二次重置 - shixun_mod = ShixunModify.where(:shixun_id => @shixun.id, :myshixun_id => @myshixun.id, :status => 1).take - shixun_mod.update_column(:status, 0) if shixun_mod - rescue Exception => e - uid_logger_error("myshixun reset failed #{e}") - raise ActiveRecord::Rollback end + # 删除版本库 + GitService.delete_repository(repo_path: @repo_path) + rescue Exception => e + if e.message != "ActiveRecord::RecordInvalid" + logger.error("######delete_repository_error:#{e.message}") + end + raise ActiveRecord::Rollback end end