// Callbacks for XML parsers
+typedef enum {
+ PARSING_PRI,
+ PARSING_FIL,
+ PARSING_OTH,
+} cr_ParsingState;
+
typedef struct {
GHashTable *ht;
GStringChunk *chunk;
primary.xml with metadata from filelists.xml and other.xml and
we want the pkgId to be unique.
Key is pkgId and value is NULL. */
+ cr_ParsingState state;
} cr_CbData;
static int
if (!epkg) {
// Store package into the hashtable
+ pkg->loadingflags |= CR_PACKAGE_FROM_XML;
+ pkg->loadingflags |= CR_PACKAGE_LOADED_PRI;
g_hash_table_replace(cb_data->ht, pkg->pkgId, pkg);
} else {
// Package with the same pkgId (hash) already exists
*pkg = g_hash_table_lookup(cb_data->ht, pkgId);
- if (*pkg && cb_data->chunk) {
- assert(!(*pkg)->chunk);
- (*pkg)->chunk = cb_data->chunk;
+ if (*pkg) {
+ // If package with the pkgId was parsed from primary.xml, then...
+
+ if (cb_data->state == PARSING_FIL) {
+ if ((*pkg)->loadingflags & CR_PACKAGE_LOADED_FIL) {
+ // For package with this checksum, the filelist was
+ // already loaded.
+ *pkg = NULL;
+ } else {
+ // Make a note that filelist is parsed
+ (*pkg)->loadingflags |= CR_PACKAGE_LOADED_FIL;
+ }
+ }
+
+ if (cb_data->state == PARSING_OTH) {
+ if ((*pkg)->loadingflags & CR_PACKAGE_LOADED_OTH) {
+ // For package with this checksum, the other (changelogs) were
+ // already loaded.
+ *pkg = NULL;
+ } else {
+ // Make a note that other is parsed
+ (*pkg)->loadingflags |= CR_PACKAGE_LOADED_OTH;
+ }
+ }
+
+ if (*pkg && cb_data->chunk) {
+ assert(!(*pkg)->chunk);
+ (*pkg)->chunk = cb_data->chunk;
+ }
}
return CR_CB_RET_OK;
assert(hashtable);
// Prepare cb data
+ cb_data.state = PARSING_PRI;
cb_data.ht = hashtable;
cb_data.chunk = chunk;
cb_data.pkglist_ht = pkglist_ht;
return code;
}
+ cb_data.state = PARSING_FIL;
+
if (filelists_xml_path) {
cr_xml_parse_filelists(filelists_xml_path,
newpkgcb,
}
}
+ cb_data.state = PARSING_OTH;
+
if (other_xml_path) {
cr_xml_parse_other(other_xml_path,
newpkgcb,
* @{
*/
+typedef enum {
+ CR_PACKAGE_FROM_HEADER = (1<<1), /*!< Metadata parsed from header */
+ CR_PACKAGE_FROM_XML = (1<<2), /*!< Metadata parsed xml */
+ /* Some values are reserved (for sqlite, solv, etc..) */
+ CR_PACKAGE_LOADED_PRI = (1<<10), /*!< Primary metadata was loaded */
+ CR_PACKAGE_LOADED_FIL = (1<<11), /*!< Filelists metadata was loaded */
+ CR_PACKAGE_LOADED_OTH = (1<<12), /*!< Other metadata was loaded */
+} cr_PackageLoadingFlags;
+
/** Dependency (Provides, Conflicts, Obsoletes, Requires).
*/
typedef struct {
GStringChunk *chunk; /*!< string chunk for store all package strings
on the single place */
+
+ cr_PackageLoadingFlags loadingflags; /*!<
+ Bitfield flags with information about package loading */
} cr_Package;
/** Create new (empty) dependency structure.