From 4db521657dda8d8276db983ee0b7de3060d5fee5 Mon Sep 17 00:00:00 2001 From: Himanshu Chhetri <himanshuchhetri@gmail.com> Date: Fri, 29 Oct 2010 20:31:45 -0700 Subject: [PATCH] Use FileUtils for all file operations. Also uses Kernel.system to execute shell commands in a secure fashion. --- lib/collect_user_photos.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/collect_user_photos.rb b/lib/collect_user_photos.rb index 4b0fedea27..d95aa386a5 100644 --- a/lib/collect_user_photos.rb +++ b/lib/collect_user_photos.rb @@ -17,12 +17,12 @@ module PhotoMover current_photo_location = "#{Rails.root}/public/uploads/images/#{photo.image_filename}" new_photo_location = "#{album_dir}/#{photo.image_filename}" - `cp #{current_photo_location} #{new_photo_location}` + FileUtils::cp current_photo_location new_photo_location end end - `tar cf #{user.id}.tar #{user.id}` - `rm -r #{user.id}` + system("tar", "cf #{user.id}.tar #{user.id}") + FileUtils::rm_r user.id, :secure => true, :force => true "#{Rails.root}/#{temp_dir}.tar" end -- GitLab