From 7acd36daa3d727eae37d540193480614ff369061 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Sun, 1 Mar 2015 06:47:38 +0100 Subject: Only accept FIT files with activity records for import --- lib/postrunner/ActivitiesDB.rb | 4 ++++ lib/postrunner/Activity.rb | 8 +++++++- lib/postrunner/Main.rb | 7 ++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/postrunner/ActivitiesDB.rb b/lib/postrunner/ActivitiesDB.rb index b66f6eb..44db6ff 100644 --- a/lib/postrunner/ActivitiesDB.rb +++ b/lib/postrunner/ActivitiesDB.rb @@ -84,6 +84,10 @@ module PostRunner Log.error $! return false end + unless fit_activity + Log.error "#{fit_file} does not contain any activity records" + return false + end begin FileUtils.cp(fit_file, @fit_dir) diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb index 0328d22..72c1e12 100644 --- a/lib/postrunner/Activity.rb +++ b/lib/postrunner/Activity.rb @@ -232,10 +232,16 @@ module PostRunner def load_fit_file(filter = nil) fit_file = File.join(@db.fit_dir, @fit_file) begin - return Fit4Ruby.read(fit_file, filter) + fit_activity = Fit4Ruby.read(fit_file, filter) rescue Fit4Ruby::Error Log.fatal $! end + + unless fit_activity + Log.fatal "#{fit_file} does not contain any activity records" + end + + fit_activity end end diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb index f368028..73f9c4a 100644 --- a/lib/postrunner/Main.rb +++ b/lib/postrunner/Main.rb @@ -190,6 +190,7 @@ EOT when 'check' if args.empty? @activities.check + @activities.generate_all_html_reports else process_files_or_activities(args, :check) end @@ -325,11 +326,7 @@ EOT end def read_fit_file(fit_file) - begin - return Fit4Ruby::read(fit_file, @filter) - rescue StandardError - Log.error("Cannot read FIT file '#{fit_file}': #{$!}") - end + return Fit4Ruby::read(fit_file, @filter) end def change_unit_system(args) -- cgit v1.2.3