diff --git a/src/gui-resource.c b/src/gui-resource.c
index fb2cf7513de7792aa7f36f0533a5dbbe9d3e2a48..9b7b31dbfa9eeed9d61c818903637c57ec1bc343 100644
--- a/src/gui-resource.c
+++ b/src/gui-resource.c
@@ -49,8 +49,7 @@ G_DEFINE_TYPE (GuiResource, gui_resource, HDY_TYPE_ACTION_ROW)
 GuiResource *
 gui_resource_new (struct Resource file_info)
 {
-  // if both or none are true, there is a problem
-  g_assert ((file_info.filename==NULL) ^ (file_info.type==RESOURCE_FOLDERFILE));
+  g_assert_nonnull (file_info.name);
   return g_object_new (HDY_TYPE_GUI_RESOURCE,
                        "resource_type",     file_info.type,
                        "resource_name",     file_info.name,
diff --git a/src/moodle-parser.c b/src/moodle-parser.c
index 70ee9304954546a26296513de0bb3066e8bd2d01..5deb0f10e1000fd491017cf7422888beaff7f408 100644
--- a/src/moodle-parser.c
+++ b/src/moodle-parser.c
@@ -131,6 +131,10 @@ moodle_parse_folder_content (const gchar *html, gsize html_size, const gchar *mo
       if (node->child && node->child->next && node->child->next->child) {
         name = g_strdup (myhtml_node_text(node->child->next->child, NULL));
       }
+      if (!name) {
+        g_warning ("Could not find the name of a file from a folder\n");
+        name = filename;
+      }
       resources[count] = (struct Resource) {type, id, name, href, filename};
       count++;
     }
@@ -231,8 +235,7 @@ moodle_extract_week (gchar *week_name, myhtml_tree_t *tree, myhtml_tree_node_t *
       resources = malloc (sizeof (struct Resource) * 1000);
 
       for (li = element->child; li; li = li->next) {
-        gchar *name;
-        gchar *textname;
+        gchar *name, *textname, *filename;
         enum resource_type type;
         guint id;
         myhtml_collection_t *hrefs = myhtml_get_nodes_by_tag_id_in_scope (tree, NULL,
@@ -246,12 +249,12 @@ moodle_extract_week (gchar *week_name, myhtml_tree_t *tree, myhtml_tree_node_t *
         }
 
         myhtml_tree_node_t *node = hrefs->list[0];
-        name = textname = NULL;
+        name = textname = filename = NULL;
         id = 0;
         for (myhtml_tree_attr_t *attr = myhtml_node_attribute_first (node); attr; attr = attr->next) {
           if (strcmp (myhtml_attribute_key (attr, NULL), "href") == 0) {
             const char *href = myhtml_attribute_value (attr, NULL);
-            type = read_link (href, &id, NULL);
+            type = read_link (href, &id, &filename);
             name = g_strdup (/*g_path_get_basename (*/href/*)*/);
             if (node->child && node->child->next && node->child->next->child) {
               textname = g_strdup (myhtml_node_text(node->child->next->child, NULL));
@@ -262,7 +265,7 @@ moodle_extract_week (gchar *week_name, myhtml_tree_t *tree, myhtml_tree_node_t *
 
         if (id && textname && name) {
           assert(resource_count<1000); // there should be no more than 1000 files a week, right ? right ??
-          resources[resource_count] = (struct Resource) {type, id, textname, name, NULL};
+          resources[resource_count] = (struct Resource) {type, id, textname, name, filename};
           resource_count++;
         } else {
           g_print ("a li doesn't have any link\n");