diff --git a/gnoemoe/mcp/gm-mcp-icecrew-userlist.c b/gnoemoe/mcp/gm-mcp-icecrew-userlist.c index b0b5fba..ef2fee6 100644 --- a/gnoemoe/mcp/gm-mcp-icecrew-userlist.c +++ b/gnoemoe/mcp/gm-mcp-icecrew-userlist.c @@ -417,7 +417,7 @@ gm_mcp_icecrew_userlist_remote_to_local_path(gchar const *url, void gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package, - gchar *path, gint n, gboolean rank) { + gchar const *path, gint n, gboolean rank) { GList *item, **alter; gint i; GmKeyValuePair *map; @@ -459,7 +459,7 @@ gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package, break; } - g_free(path); + g_free(pathd); } } @@ -576,8 +576,6 @@ gm_mcp_icecrew_userlist_fetch_next_alternatives(GmMcpIcecrewUserlist *package, gchar *prev_name = NULL, *path; GList *item, **alter, *iter; GmKeyValuePair *map, *itermap; - GnomeVFSResult result; - GnomeVFSFileInfo *finfo; /* Select unique name alternatives */ alter = rank ? &(package->priv->rank_alternatives) : @@ -593,53 +591,38 @@ gm_mcp_icecrew_userlist_fetch_next_alternatives(GmMcpIcecrewUserlist *package, /* Skip alternatives with names we've already stored to be fetched */ if (prev_name == NULL || (map->key != NULL && strcmp(map->key, prev_name) != 0)) { - finfo = gnome_vfs_file_info_new(); - result = gnome_vfs_get_file_info(map->value, finfo, - GNOME_VFS_FILE_INFO_DEFAULT); - gnome_vfs_file_info_unref(finfo); - - if (result != GNOME_VFS_OK) { - gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist." - "FetchNextAlternatives: removing %s because it's " - "invalid: %s", map->value, - gnome_vfs_result_to_string(result)); - item = item->next; + prev_name = map->key; - *alter = g_list_remove(*alter, map); - gm_mcp_icecrew_userlist_pair_free(map); - } else { - prev_name = map->key; + path = gm_mcp_icecrew_userlist_remote_to_local_path(map->value, + rank ? package->priv->rank_dir : + package->priv->state_dir); + + gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist." + "FetchNextAlternatives: adding to be fetched: %s => %s", + map->key, map->value); - path = gm_mcp_icecrew_userlist_remote_to_local_path(map->value, - rank ? package->priv->rank_dir : - package->priv->state_dir); - - gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist." - "FetchNextAlternatives: adding to be fetched: %s => %s", - map->key, map->value); - - source_uri = g_list_append(source_uri, map->value); - dest_uri = g_list_append(dest_uri, path); - - unlink(path); - - for (iter = rank ? package->priv->rank_icons : - package->priv->state_icons; iter; iter = iter->next) { - itermap = (GmKeyValuePair *)(iter->data); - - if (itermap->key != NULL && - strcmp(itermap->key, map->key) == 0) { - g_free(itermap->value); - itermap->value = g_strdup(path); - break; - } + source_uri = g_list_append(source_uri, map->value); + dest_uri = g_list_append(dest_uri, path); + + unlink(path); + + for (iter = rank ? package->priv->rank_icons : + package->priv->state_icons; iter; iter = iter->next) { + itermap = (GmKeyValuePair *)(iter->data); + + if (itermap->key != NULL && + strcmp(itermap->key, map->key) == 0) { + g_free(itermap->value); + itermap->value = g_strdup(path); + break; } - - item = item->next; - } - } else { - item = item->next; + } } + + if (source_uri != NULL) + break; + + item = item->next; } if (source_uri != NULL) { @@ -682,6 +665,11 @@ gm_mcp_icecrew_userlist_fetch_progress(GmFetchHandle *g, if (g->done) { gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist.FetchProgress: " "fetch done!"); + + /* Remove this one from the alternatives */ + gm_mcp_icecrew_userlist_remove_alternatives(package, + gnome_vfs_uri_get_path((GnomeVFSURI *)(g->dest_uri->data)), + 1, rank); if (rank) { package->priv->rank_fetch = NULL; @@ -697,9 +685,6 @@ gm_mcp_icecrew_userlist_fetch_progress(GmFetchHandle *g, if (g->status == GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR) { /* Skip to the next alternative (in the next run, see on done */ gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist.FetchProgress: error"); - path = gnome_vfs_get_local_path_from_uri(g->cur_file_name); - gm_mcp_icecrew_userlist_remove_alternatives(package, path, 1, rank); - g_free(path); } if (g->cur_phase == GNOME_VFS_XFER_PHASE_FILECOMPLETED) {