// Recursive walk
- GHashTable *pkglist_ht = g_hash_table_new(g_str_hash, g_str_equal);
- /* ^^^ Hashtable with basenames of files which will be processed */
+ GSList *current_pkglist = NULL;
+ /* ^^^ List with basenames of files which will be processed */
int package_count = 0;
if (!(cmd_options->include_pkgs)) {
task->path = g_strdup(dirname);
if (output_pkg_list)
fprintf(output_pkg_list, "%s\n", repo_relative_path);
- g_hash_table_insert(pkglist_ht, task->filename, NULL);
+ current_pkglist = g_slist_prepend(current_pkglist, task->filename);
// TODO: One common path for all tasks with the same path?
g_thread_pool_push(pool, task, NULL);
package_count++;
task->path = strndup(relative_path, x); // packages/i386/
if (output_pkg_list)
fprintf(output_pkg_list, "%s\n", relative_path);
- g_hash_table_insert(pkglist_ht, task->filename, NULL);
+ current_pkglist = g_slist_prepend(current_pkglist, task->filename);
g_thread_pool_push(pool, task, NULL);
package_count++;
}
else
old_metadata_location = cr_get_metadata_location(in_dir, 1);
- ret = cr_load_xml_metadata(old_metadata, old_metadata_location, pkglist_ht);
+ ret = cr_load_xml_metadata(old_metadata,
+ old_metadata_location,
+ current_pkglist);
if (ret == CR_LOAD_METADATA_OK)
g_debug("Old metadata from: %s - loaded", out_dir);
else
g_message("Loading metadata from: %s", path);
ret = cr_locate_and_load_xml_metadata(old_metadata,
path,
- pkglist_ht);
+ current_pkglist);
if (ret == CR_LOAD_METADATA_OK)
g_debug("Metadata from md-path %s - loaded", path);
else
g_hash_table_size(old_metadata->ht));
}
- g_hash_table_destroy(pkglist_ht);
- pkglist_ht = NULL;
+ g_slist_free(current_pkglist);
+ current_pkglist = NULL;
// Copy groupfile
basename,
NULL,
NULL);
+ if (store)
+ // remove pkg from allowed packages
+ g_hash_table_remove(ppd->pkglist, basename);
}
if (ppd->chunk)
int
load_xml_files(GHashTable *hashtable, const char *primary_xml_path,
const char *filelists_xml_path, const char *other_xml_path,
- GStringChunk *chunk, GHashTable *pkglist)
+ GStringChunk *chunk, GSList *pkglist)
{
cr_CompressionType compression_type;
CR_FILE *pri_xml_cwfile, *fil_xml_cwfile, *oth_xml_cwfile;
XML_Parser pri_p, fil_p, oth_p;
struct ParserData parser_data;
+ GHashTable *pkglist_ht = NULL;
// Detect compression type
}
+ // Create hashtable from pkglist
+ // This hashtable is used for checking if the metadata of the package
+ // should be included.
+ // Purpose is to save memory - We load only metadata about
+ // packages which we probably will use
+ // This hashtable is modified "on the fly" - If we found and load
+ // a metadata about the package, we remove its record from the hashtable.
+ // So if we met the metadata for this package again we will ignore it.
+
+ if (pkglist) {
+ GSList *elem;
+ pkglist_ht = g_hash_table_new(g_str_hash, g_str_equal);
+ for (elem = pkglist; elem; elem = g_slist_next(elem))
+ g_hash_table_insert(pkglist_ht, elem->data, NULL);
+ }
+
// Prepare parsers
parser_data.current_string = g_string_sized_new(1024);
parser_data.last_elem = NONE_ELEM;
parser_data.error = FALSE;
parser_data.chunk = chunk;
- parser_data.pkglist = pkglist;
+ parser_data.pkglist = pkglist_ht;
pri_p = XML_ParserCreate(NULL);
XML_SetUserData(pri_p, (void *) &parser_data);
// Cleanup
+ if (pkglist_ht) g_hash_table_destroy(pkglist_ht);
XML_ParserFree(pri_p);
XML_ParserFree(fil_p);
XML_ParserFree(oth_p);
int
cr_load_xml_metadata(cr_Metadata md,
struct cr_MetadataLocation *ml,
- GHashTable *pkglist)
+ GSList *pkglist)
{
if (!md || !ml)
return CR_LOAD_METADATA_ERR;
int
cr_locate_and_load_xml_metadata(cr_Metadata md,
const char *repopath,
- GHashTable *pkglist)
+ GSList *pkglist)
{
if (!md || !repopath)
return CR_LOAD_METADATA_ERR;
* Load metadata from the specified location.
* @param md metadata object
* @param ml metadata location
- * @param pkglist load only packages which base filename is as a key
- * in this hashtable (value is ignored). If param is
- * NULL all packages are loaded.
+ * @param pkglist load only packages which base filename is in this
+ * list. If param is NULL all packages are loaded.
* @return return code CR_LOAD_METADATA_OK or CR_LOAD_METADATA_ERR
*/
int cr_load_xml_metadata(cr_Metadata md,
struct cr_MetadataLocation *ml,
- GHashTable *pkglist);
+ GSList *pkglist);
/** \ingroup load_metadata
* Locate and load metadata from the specified path.
* @param md metadata object
* @param repopath path to repo (to directory with repodata/ subdir)
- * @param pkglist load only packages which base filename is as a key
- * in this hashtable (value is ignored). If param is
- * NULL all packages are loaded.
+ * @param pkglist load only packages which base filename is in this
+ * list. If param is NULL all packages are loaded.
* @return return code CR_LOAD_METADATA_OK or CR_LOAD_METADATA_ERR
*/
int cr_locate_and_load_xml_metadata(cr_Metadata md,
const char *repopath,
- GHashTable *pkglist);
+ GSList *pkglist);
#ifdef __cplusplus
}