From 868cb1efc1959dee8b39f6a1439a726cb0b2f26e Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Fri, 7 Jan 2011 10:57:37 -0800 Subject: [PATCH] checking that filepath exists --- lib/tasks/backup.rake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/tasks/backup.rake b/lib/tasks/backup.rake index 740ddbb22..f63302f46 100644 --- a/lib/tasks/backup.rake +++ b/lib/tasks/backup.rake @@ -47,12 +47,16 @@ namespace :backup do (0..99).each do |n| padded_str = n.to_s.rjust(2,'0') file = photo_container.create_object(tar_name + padded_str) - if file.write File.open("/tmp/backup/" + tar_name + padded_str) - puts("event=backup status=success type=photos") - else - puts("event=backup status=failure type=photos") + file_path = "/tmp/backup/" + tar_name + padded_str + + if File.exists?(file_path) + if file.write File.open(file_path) + puts("event=backup status=success type=photos") + else + puts("event=backup status=failure type=photos") + end + `rm #{file_path}` end - `rm /tmp/backup/#{tar_name + padded_str}` end else