replaced system() calls with FileUtils.* method

This also makes that 'mv: cannot stat `/ho..' is not shown in the test :)

consistent spacing

require fileutils

Revert "require fileutils"

This reverts commit 54313d3bbaa60cfc5b405be50cc00b7f6b0cb715.

new hash notation

FileUtils.mv in begin/rescue block
This commit is contained in:
Koen Punt 2012-12-07 01:51:49 +01:00
parent 2095780f24
commit 6b9177ca02
2 changed files with 12 additions and 10 deletions

View file

@ -52,7 +52,7 @@ class Namespace < ActiveRecord::Base
def ensure_dir_exist
unless dir_exists?
system("mkdir -m 770 #{namespace_full_path}")
FileUtils.mkdir( namespace_full_path, mode: 0770 )
end
end
@ -71,11 +71,12 @@ class Namespace < ActiveRecord::Base
if File.exists?(new_path)
raise "Already exists"
end
if system("mv #{old_path} #{new_path}")
begin
FileUtils.mv( old_path, new_path )
send_update_instructions
@require_update_gitolite = true
else
rescue Exception => e
raise "Namespace move error #{old_path} #{new_path}"
end
end
@ -88,7 +89,7 @@ class Namespace < ActiveRecord::Base
def rm_dir
dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
system("rm -rf #{dir_path}")
FileUtils.rm_r( dir_path, force: true )
end
def send_update_instructions