将删除版本库的操作置入后台
This commit is contained in:
parent
273b360b51
commit
38ec84cde9
|
@ -236,24 +236,10 @@ update
|
|||
end
|
||||
|
||||
def destroy
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repo_name=User.current.login.to_s+"_"+@repository.identifier.to_s
|
||||
@repository_name=User.current.login.to_s+"/"+@repository.identifier.to_s+".git"
|
||||
@middle=User.current.login.to_s+"_"+@repository.identifier.to_s+"-write:"
|
||||
@repository.destroy if request.delete?
|
||||
DestroyRepositoryTask.new.destroy(User.current.id, @repository.id)
|
||||
@repository.hidden = true
|
||||
@repository.save
|
||||
redirect_to settings_project_url(@project, :tab => 'repositories')
|
||||
if(@repository.type=="Repository::Git")
|
||||
logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+
|
||||
"repository_name"+@repository_name+"user group"+@middle
|
||||
system "sed -i /"+@repo_name+"/{d} "+@root_path+"htdocs/user.passwd"
|
||||
system "sed -i /"+@middle+"/{d} "+@root_path+"htdocs/group.passwd"
|
||||
system "rm -r "+@root_path+"htdocs/"+@repository_name
|
||||
# if(@sed_user&&@sed_group&&@remove)
|
||||
# else
|
||||
# logger.info "An error occured when destory the repository"+"delete form passwd: \n"+
|
||||
# @sed_user+"delete from group"+@sed_group+"delete from file"+@remove
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -51,7 +51,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name"
|
||||
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||
has_one :repository, :conditions => ["is_default = ?", true]
|
||||
has_many :repositories, :dependent => :destroy
|
||||
has_many :repositories, :dependent => :destroy, conditions: "hidden=false"
|
||||
has_many :changesets, :through => :repository
|
||||
#added by xianbo for delete biding_project
|
||||
has_many :biding_projects, :dependent => :destroy
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#coding=utf-8
|
||||
#
|
||||
|
||||
class DestroyRepositoryTask
|
||||
def destroy(user_id, rep_id)
|
||||
user = User.find(user_id)
|
||||
repository = Repository.find(rep_id)
|
||||
|
||||
Rails.logger.info "start delete repository #{user} #{repository}"
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repo_name=user.login.to_s+"_"+repository.identifier.to_s
|
||||
@repository_name=user.login.to_s+"/"+repository.identifier.to_s+".git"
|
||||
@middle=user.login.to_s+"_"+repository.identifier.to_s+"-write:"
|
||||
repository.destroy
|
||||
if(repository.type=="Repository::Git")
|
||||
Rails.logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+
|
||||
"repository_name"+@repository_name+"user group"+@middle
|
||||
system "sed -i /"+@repo_name+"/{d} "+@root_path+"htdocs/user.passwd"
|
||||
system "sed -i /"+@middle+"/{d} "+@root_path+"htdocs/group.passwd"
|
||||
system "rm -r "+@root_path+"htdocs/"+@repository_name
|
||||
end
|
||||
end
|
||||
|
||||
handle_asynchronously :destroy,:queue => 'repository'
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddHiddenToRepositories < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :repositories, :hidden, :boolean, default: false
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150422034543) do
|
||||
ActiveRecord::Schema.define(:version => 20150428021035) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1058,6 +1058,7 @@ ActiveRecord::Schema.define(:version => 20150422034543) do
|
|||
t.text "extra_info"
|
||||
t.string "identifier"
|
||||
t.boolean "is_default", :default => false
|
||||
t.boolean "hidden", :default => false
|
||||
end
|
||||
|
||||
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
|
||||
|
|
Loading…
Reference in New Issue