From 21af11b4fff1a669d87d9d17d35da52eabf9006d Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Wed, 3 Jul 2013 11:18:25 -0700 Subject: [PATCH] Validate that files exist before attempting to copy them to reduce errors --- lib/abusetheforce/cli.rb | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/abusetheforce/cli.rb b/lib/abusetheforce/cli.rb index dd82aff..0e43b4f 100644 --- a/lib/abusetheforce/cli.rb +++ b/lib/abusetheforce/cli.rb @@ -98,16 +98,23 @@ module AbuseTheForce FileUtils.mkdir_p File.join(temp_path, mdir) # Copy the file - FileUtils.copy( - File.join(fpath), - File.join(temp_path, mdir, '/') - ) + if File.exists? fpath + FileUtils.copy( + File.join(fpath), + File.join(temp_path, mdir, '/') + ) + else + pute("File not found...") + return false + end # Copy the metadata - FileUtils.copy( - File.join(fpath + '-meta.xml'), - File.join(temp_path, mdir, '/') - ) + if File.exists? fpath + '-meta.xml' + FileUtils.copy( + File.join(fpath + '-meta.xml'), + File.join(temp_path, mdir, '/') + ) + end return true end