summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2015-03-01 06:47:38 +0100
committerChris Schlaeger <chris@linux.com>2015-03-01 06:47:38 +0100
commit7acd36daa3d727eae37d540193480614ff369061 (patch)
tree9d79f4b94ad31b87c9235dc3b9ba23b33b111fa6 /lib
parentbdc7d05a19747b68d10eb0303c3472571aa3ce61 (diff)
downloadpostrunner-7acd36daa3d727eae37d540193480614ff369061.zip
Only accept FIT files with activity records for import
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/ActivitiesDB.rb4
-rw-r--r--lib/postrunner/Activity.rb8
-rw-r--r--lib/postrunner/Main.rb7
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)