Use FileUtils for all file operations. Also uses Kernel.system to execute shell commands in a secure fashion.

This commit is contained in:
Himanshu Chhetri 2010-10-29 20:31:45 -07:00
parent 07a54fea04
commit 4db521657d

View file

@ -17,12 +17,12 @@ module PhotoMover
current_photo_location = "#{Rails.root}/public/uploads/images/#{photo.image_filename}" current_photo_location = "#{Rails.root}/public/uploads/images/#{photo.image_filename}"
new_photo_location = "#{album_dir}/#{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
end end
`tar cf #{user.id}.tar #{user.id}` system("tar", "cf #{user.id}.tar #{user.id}")
`rm -r #{user.id}` FileUtils::rm_r user.id, :secure => true, :force => true
"#{Rails.root}/#{temp_dir}.tar" "#{Rails.root}/#{temp_dir}.tar"
end end