Merge pull request #2207 from koenpunt/system-to-fileutils

replaced system() calls with FileUtils.* methods
This commit is contained in:
Dmitriy Zaporozhets 2013-01-05 10:03:13 -08:00
commit 9f1a4acf62
2 changed files with 12 additions and 10 deletions

View file

@ -16,7 +16,7 @@ module Gitlab
def execute
# Create new dir if missing
new_dir_path = File.join(Gitlab.config.gitolite.repos_path, new_dir)
system("mkdir -m 770 #{new_dir_path}") unless File.exists?(new_dir_path)
FileUtils.mkdir( new_dir_path, mode: 0770 ) unless File.exists?(new_dir_path)
old_path = File.join(Gitlab.config.gitolite.repos_path, old_dir, "#{project.path}.git")
new_path = File.join(new_dir_path, "#{project.path}.git")
@ -25,17 +25,18 @@ module Gitlab
raise ProjectMoveError.new("Destination #{new_path} already exists")
end
if system("mv #{old_path} #{new_path}")
begin
FileUtils.mv( old_path, new_path )
log_info "Project #{project.name} was moved from #{old_path} to #{new_path}"
true
else
rescue Exception => e
message = "Project #{project.name} cannot be moved from #{old_path} to #{new_path}"
log_info "Error! #{message}"
log_info "Error! #{message} (#{e.message})"
raise ProjectMoveError.new(message)
end
end
protected
protected
def log_info message
Gitlab::AppLogger.info message