lib/relaton_3gpp/data_fetcher.rb in relaton-3gpp-1.14.5 vs lib/relaton_3gpp/data_fetcher.rb in relaton-3gpp-1.14.6

- old
+ new

@@ -70,25 +70,28 @@ File.write CURRENT, @current.to_yaml, encoding: "UTF-8" index.save end # - # Get file from FTP + # Get file from FTP. If file does not exist or changed, return nil # # @param [Boolean] renewal force to update all documents # - # @return [String] file name + # @return [String, nil] file name # def get_file(renewal) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity @current = YAML.load_file CURRENT if File.exist? CURRENT @current ||= {} n = 0 begin ftp = Net::FTP.new("www.3gpp.org") ftp.resume = true ftp.login ftp.chdir "/Information/Databases/Spec_Status/" - d, t, _, file = ftp.list("*.zip").first.split + file_path = ftp.list("*.zip").first + return unless file_path + + d, t, _, file = file_path.split unless renewal dt = DateTime.strptime("#{d} #{t}", "%m-%d-%y %I:%M%p") return if file == @current["file"] && !@current["date"].empty? && dt == DateTime.parse(@current["date"]) end