[libgweather/wip/hadess/fix-invalid-forecast: 5/5] yrno: Fix forecasts never being available because invalid



commit d45d5a84c4a836f081dd01bf703e23f5b651bc29
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Aug 27 15:07:35 2019 +0300

    yrno: Fix forecasts never being available because invalid
    
    yrno was never setting the "valid" flag on the main info struct, just on
    each one of the info structs created to hold the forecasts, so it was
    impossible to get the forecasts unless *another* provider succeeded.
    
    This fixes fetching forecasts for Helsinki, as METAR fetching fails and
    YR.NO didn't set the valid flag.
    
    Closes: #11

 libgweather/weather-yrno.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/libgweather/weather-yrno.c b/libgweather/weather-yrno.c
index ace74e9..e47dd35 100644
--- a/libgweather/weather-yrno.c
+++ b/libgweather/weather-yrno.c
@@ -391,6 +391,7 @@ yrno_finish_new (SoupSession *session,
     GWeatherInfo *info = GWEATHER_INFO (user_data);
     GWeatherInfoPrivate *priv;
     WeatherLocation *loc;
+    guint num_forecasts;
 
     if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
        /* forecast data is not really interesting anyway ;) */
@@ -407,6 +408,10 @@ yrno_finish_new (SoupSession *session,
     g_debug ("%s", msg->response_body->data);
 
     parse_forecast_xml_new (info, msg->response_body);
+    num_forecasts = g_slist_length (priv->forecast_list);
+    g_debug ("yrno parsed %d forecast infos", num_forecasts);
+    if (!priv->valid)
+        priv->valid = (num_forecasts > 0);
 
     _gweather_info_request_done (info, msg);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]