diff options
author | Chris Schlaeger <chris@linux.com> | 2020-08-30 20:18:24 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2020-08-30 20:18:24 +0200 |
commit | 79e947d6a3d10dab9c20408f553759b02fbdb556 (patch) | |
tree | 1b706333f13764699eda8a3032667ce6e7be7224 /lib | |
parent | 0c8c8469468ef40c20764a4c6d95fe5b7235eb35 (diff) | |
download | postrunner-79e947d6a3d10dab9c20408f553759b02fbdb556.zip |
Fix: Fix import of monitoring files.
Monitoring files don't have an indexed device info section. The old code
did not like that.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/postrunner/FitFileStore.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb index 329fb69..a7d7ebf 100644 --- a/lib/postrunner/FitFileStore.rb +++ b/lib/postrunner/FitFileStore.rb @@ -144,7 +144,9 @@ module PostRunner # Generate a String that uniquely identifies the device that generated # the FIT file. - id = extract_fit_file_id(fit_entity) + unless (id = extract_fit_file_id(fit_entity)) + return nil + end long_uid = "#{id[:numeric_manufacturer]}-" + "#{id[:numeric_product]}-#{id[:serial_number]}" @@ -503,7 +505,12 @@ module PostRunner end fit_entity.device_infos.each do |di| - if di.device_index == 0 + # Not all FIT file have indexed device sections. In case the device + # index is nil we'll take the first entry. + if (di.device_index.nil? || di.device_index == 0) && + (di.manufacturer && + (di.garmin_product || di.product) && + di.numeric_product && di.serial_number) return { :manufacturer => di.manufacturer, :product => di.garmin_product || di.product, @@ -514,7 +521,7 @@ module PostRunner end end - Log.error "Fit entity has no device info for 0" + Log.error "Fit entity has no device info section" return nil end |