trustieforge/app/tasks/destroy_repository_task.rb

26 lines
995 B
Ruby

#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