lib/eco-rake/lib/people/sync_process.rb in eco-rake-0.1.1 vs lib/eco-rake/lib/people/sync_process.rb in eco-rake-0.1.2
- old
+ new
@@ -15,11 +15,13 @@
option_reopen :folder, default_lookup: :local_folder
def task(*_args)
upsert_local_dir(options[:folder])
sh_continue rake_sftp_get
- sh rake_decrypt if do_decrypt
+ if do_decrypt
+ failed_decryption_notify unless 0 == sh_continue(rake_decrypt)
+ end
sh_continue rake_sync_command
return if options[:simulate]
sh_continue rake_sftp_archive
sh_continue rake_files_purge('cache')
sh_continue rake_files_purge('requests')
@@ -39,9 +41,18 @@
array_cmd('rake csv:decrypt', '--', forward_option(:folder)).join(" ")
end
def rake_files_purge(folder, operation: '--remove')
rake_command('logs:purge', *forward_options(:enviro), "-d #{folder}", operation)
+ end
+
+ def failed_decryption_notify
+ msg = 'File decryption failed'
+ puts msg
+ exit 1 if options[:simulate]
+ exit 1 unless inbox = mail_to
+ email(enviro: target_enviro, to: inbox, subject: msg, body: msg)
+ exit 1
end
end
end
end
end