summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/postrunner/Activity.rb3
-rw-r--r--lib/postrunner/FFS_Activity.rb1
-rw-r--r--lib/postrunner/FitFileStore.rb23
-rw-r--r--lib/postrunner/Main.rb6
4 files changed, 23 insertions, 10 deletions
diff --git a/lib/postrunner/Activity.rb b/lib/postrunner/Activity.rb
index e92a105..d169461 100644
--- a/lib/postrunner/Activity.rb
+++ b/lib/postrunner/Activity.rb
@@ -95,6 +95,7 @@ module PostRunner
'challenge' => 'Challenge',
'indoor_skiing' => 'Indoor Skiing',
'cardio_training' => 'Cardio Training',
+ 'virtual_activity' => 'Virtual Activity',
'all' => 'All'
}
@@ -379,7 +380,7 @@ module PostRunner
end
def activity_sub_type
- ActivitySubTypes[@sub_sport] || 'Undefined'
+ ActivitySubTypes[@sub_sport] || 'Undefined "#{@sub_sport}"'
end
def distance(timestamp, unit_system)
diff --git a/lib/postrunner/FFS_Activity.rb b/lib/postrunner/FFS_Activity.rb
index 4c66857..ef6e17d 100644
--- a/lib/postrunner/FFS_Activity.rb
+++ b/lib/postrunner/FFS_Activity.rb
@@ -93,6 +93,7 @@ module PostRunner
'challenge' => 'Challenge',
'indoor_skiing' => 'Indoor Skiing',
'cardio_training' => 'Cardio Training',
+ 'virtual_activity' => 'Virtual Activity',
'all' => 'All'
}
diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb
index 6ee484f..0b1a704 100644
--- a/lib/postrunner/FitFileStore.rb
+++ b/lib/postrunner/FitFileStore.rb
@@ -80,13 +80,7 @@ module PostRunner
# @return [FFS_Activity or FFS_Monitoring] Corresponding entry in the
# FitFileStore or nil if file could not be added.
def add_fit_file(fit_file_name, fit_entity = nil, overwrite = false)
- md5sum = FitFileStore.calc_md5_sum(fit_file_name)
- if @store['fit_file_md5sums'].include?(md5sum)
- # The FIT file is already stored in the DB.
- return nil unless overwrite
- end
-
- # If we the file hasn't been read yet, read it in as a
+ # If the file hasn't been read yet, read it in as a
# Fit4Ruby::Activity or Fit4Ruby::Monitoring entity.
unless fit_entity
return nil unless (fit_entity = read_fit_file(fit_file_name))
@@ -451,7 +445,8 @@ module PostRunner
def extract_fit_file_id(fit_entity)
unless (fid = fit_entity.file_id)
- Log.fatal 'FIT file has no file_id section'
+ Log.error 'FIT file has no file_id section'
+ return nil
end
if fid.manufacturer == 'garmin' &&
@@ -470,10 +465,20 @@ module PostRunner
}
end
end
- Log.fatal "Fit entity has no device info for 0"
+ Log.error "Fit entity has no device info for 0"
+ return nil
else
# And for all properly developed devices we can just look at the
# file_id section.
+ if fid.manufacturer.nil? ||
+ fid.manufacturer[0..'Undocumented value'.length - 1] ==
+ 'Undocumented value'
+ Log.error "Cannot store FIT files for unknown manufacturer " +
+ fid.manufacturer
+ return nil
+ end
+ fid.serial_number ||= 0
+
return {
:manufacturer => fid.manufacturer,
:product => fid.garmin_product || fid.product,
diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb
index e988b4e..2717e0e 100644
--- a/lib/postrunner/Main.rb
+++ b/lib/postrunner/Main.rb
@@ -472,6 +472,12 @@ EOT
# @return [TrueClass, FalseClass] true if file was successfully imported,
# false otherwise
def import_fit_file(fit_file_name)
+ md5sum = FitFileStore.calc_md5_sum(fit_file_name)
+ if @ffs.store['fit_file_md5sums'].include?(md5sum)
+ # The FIT file is already stored in the DB.
+ return nil unless @force
+ end
+
begin
fit_entity = Fit4Ruby.read(fit_file_name)
rescue Fit4Ruby::Error