From b8de6a9d10865e60a0fe12c37099967ed295a05a Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 10 Jul 2020 20:42:51 +0800 Subject: [PATCH] change bugs --- app/jobs/sync_repository_job.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/jobs/sync_repository_job.rb b/app/jobs/sync_repository_job.rb index a2b10d94d..b7fac4127 100644 --- a/app/jobs/sync_repository_job.rb +++ b/app/jobs/sync_repository_job.rb @@ -7,12 +7,18 @@ class SyncRepositoryJob < ApplicationJob #创建临时文件夹 clone 并强推代码 SyncLog.sync_log("=================begin to sync request trustie repository=====================") path = "#{Rails.root}/public/cache_repository" - unless File.directory?(path) - FileUtils.mkdir_p(path) - end image_url = repository_params[:git_url] g_default_branch = repository_params[:default_branch] image_repo_name = image_url.to_s.split('/')&.last&.chomp('.git') + + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + + if Dir.exist?("#{path}/#{image_repo_name}") + system("rm -rf #{path}/#{image_repo_name}") + end + check_clone = system("cd #{path} and git clone #{image_url}") SyncLog.sync_log("========check_clone:====cd #{path} and git clone #{image_url}===================") if check_clone