Never give up
Revisión | 3ca60ca1bd36e7394c9e8671d26532d29d1a13da (tree) |
---|---|
Tiempo | 2013-10-29 23:52:20 |
Autor | HMML <hmml3939@gmai...> |
Commiter | HMML |
Keep archive and send notify when upload failed.
@@ -87,7 +87,7 @@ GEM | ||
87 | 87 | coffee-script-source (1.6.3) |
88 | 88 | diff-lcs (1.2.4) |
89 | 89 | erubis (2.7.0) |
90 | - exception_notification (4.0.0) | |
90 | + exception_notification (4.0.1) | |
91 | 91 | actionmailer (>= 3.0.4) |
92 | 92 | activesupport (>= 3.0.4) |
93 | 93 | execjs (2.0.2) |
@@ -48,6 +48,14 @@ class VoicePreview < Paperclip::Processor | ||
48 | 48 | system(*['sox', tfiles.sort, dst_path].flatten) or raise "Failed to concat, sox fail (#{$?})" |
49 | 49 | rescue => e |
50 | 50 | Rails.logger.error "Error: Failed to generate preview voice: #{e.message}" |
51 | + FileUtils.mkdir_p "#{Rails.root}/tmp/failed" | |
52 | + failed_path = "#{Rails.root}/tmp/failed/#{Time.now.to_i}.zip" | |
53 | + Rails.logger.error "Keeping failed archive to '#{failed_path}'" | |
54 | + FileUtils.cp @file.path, failed_path | |
55 | + env = ENV.to_hash | |
56 | + env['SAVED_ARCHIVE'] = failed_path | |
57 | + defined?(ExceptionNotifier) and | |
58 | + ExceptionNotifier::Notifier.exception_notification(env, e).deliver | |
51 | 59 | raise Paperclip::Error, "Error: Failed to generate preview voice: #{e.message}" |
52 | 60 | ensure |
53 | 61 | FileUtils.remove_entry_secure tmpdir |