From be2ad2d0ae9f959677a4bfa25e80d398431d2464 Mon Sep 17 00:00:00 2001 From: Chris Schlaeger Date: Mon, 17 Aug 2020 18:47:42 +0200 Subject: Fix: Fix undefined local variable or method 'di' error --- lib/postrunner/FitFileStore.rb | 50 ++++++++++-------------------------------- lib/postrunner/Main.rb | 1 - 2 files changed, 12 insertions(+), 39 deletions(-) (limited to 'lib') diff --git a/lib/postrunner/FitFileStore.rb b/lib/postrunner/FitFileStore.rb index f2e80b6..329fb69 100644 --- a/lib/postrunner/FitFileStore.rb +++ b/lib/postrunner/FitFileStore.rb @@ -502,46 +502,20 @@ module PostRunner return nil end - if fid.manufacturer == 'garmin' && - fid.garmin_product == 'fr920xt' - # Garmin Fenix3 with firmware before 6.80 is reporting 'fr920xt' in - # the file_id section but 'fenix3' in the first device_info section. - # To tell the Fenix3 apart from the FR920XT we need to look into the - # device_info section for all devices with a garmin_product of - # 'fr920xt'. - fit_entity.device_infos.each do |di| - if di.device_index == 0 - return { - :manufacturer => di.manufacturer, - :product => di.garmin_product || di.product, - :numeric_manufacturer => di.numeric_manufacturer, - :numeric_product => di.numeric_product, - :serial_number => di.serial_number - } - end + fit_entity.device_infos.each do |di| + if di.device_index == 0 + return { + :manufacturer => di.manufacturer, + :product => di.garmin_product || di.product, + :numeric_manufacturer => di.numeric_manufacturer, + :numeric_product => di.numeric_product, + :serial_number => di.serial_number || 0 + } end - 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, - :numeric_manufacturer => di.numeric_manufacturer, - :numeric_product => di.numeric_product, - :serial_number => fid.serial_number - } end + + Log.error "Fit entity has no device info for 0" + return nil end def register_device(long_uid) diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb index 6ad96ee..883d2ec 100644 --- a/lib/postrunner/Main.rb +++ b/lib/postrunner/Main.rb @@ -597,7 +597,6 @@ EOT def handle_version_update if @db['config']['version'] != VERSION - puts "Work needed" from_version = Gem::Version.new(@db['config']['version']) to_version = Gem::Version.new(VERSION) -- cgit v1.2.3