Add handling into mergerepo if download of repodata failed
authorTomas Mlcoch <tmlcoch@redhat.com>
Mon, 28 May 2012 08:01:59 +0000 (10:01 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Mon, 28 May 2012 08:01:59 +0000 (10:01 +0200)
src/mergerepo_c.c

index 8d9e3fa..285dcb7 100644 (file)
@@ -581,12 +581,27 @@ int main(int argc, char **argv)
     GSList *local_repos = NULL;
     GSList *element = NULL;
     gchar *groupfile = NULL;
+    gboolean download_failed = FALSE;
 
     for (element = cmd_options->repo_list; element; element = g_slist_next(element)) {
         struct MetadataLocation *loc = get_metadata_location((gchar *) element->data);
+        if (!loc) {
+            download_failed = TRUE;
+            break;
+        }
         local_repos = g_slist_prepend(local_repos, loc);
     }
 
+    if (download_failed) {
+        g_warning("Downloading of repodata failed");
+        // Remove downloaded metadata and free structures
+        for (element = local_repos; element; element = g_slist_next(element)) {
+            struct MetadataLocation *loc = (struct MetadataLocation  *) element->data;
+            free_metadata_location(loc);
+        }
+        return 1;
+    }
+
 
     // Get first groupfile