#include "xml_dump.h"
+#define DEFAULT_CHECKSUM CR_CHECKSUM_SHA256
+
/**
* Command line options
*/
options->chcksum_type = NULL;
options->local_sqlite = FALSE;
options->compression_type = CR_CW_BZ2_COMPRESSION;
- options->checksum_type = CR_CHECKSUM_SHA256;
+ options->checksum_type = CR_CHECKSUM_UNKNOWN;
return options;
}
cr_repomd_record_load_contentstat(fil_db_rec, fil_db_task->stat);
cr_repomd_record_load_contentstat(oth_db_rec, oth_db_task->stat);
- printf("%s\n", pri_db_task->stat->checksum);
- printf("%s\n", pri_db_rec->checksum ? pri_db_rec->checksum : "");
- printf("%s\n", pri_db_rec->checksum_type ? pri_db_rec->checksum_type : "");
- printf("%s\n", pri_db_rec->checksum_open ? pri_db_rec->checksum_open : "");
- printf("%s\n", pri_db_rec->checksum_open_type ? pri_db_rec->checksum_open_type : "");
-
// Free the compression tasks
cr_compressiontask_free(pri_db_task, NULL);
cr_compressiontask_free(fil_db_task, NULL);
return FALSE;
}
+ // Auto-detect used checksum algorithm if not specified explicitly
+ if (checksum_type == CR_CHECKSUM_UNKNOWN) {
+ cr_RepomdRecord *rec = cr_repomd_get_record(repomd, "primary");
+
+ if (!rec) {
+ g_set_error(err, CREATEREPO_C_ERROR, CRE_ERROR,
+ "repomd.xml is missing primary metadata");
+ return FALSE;
+ }
+
+ if (rec->checksum_type)
+ checksum_type = cr_checksum_type(rec->checksum_type);
+ else if (rec->checksum_open_type)
+ checksum_type = cr_checksum_type(rec->checksum_open_type);
+
+ if (checksum_type == CR_CHECKSUM_UNKNOWN) {
+ g_debug("Cannot auto-detect checksum type, using default %s",
+ cr_checksum_name_str(DEFAULT_CHECKSUM));
+ checksum_type = DEFAULT_CHECKSUM;
+ }
+ }
+
// Open sqlite databases
_cleanup_free_ gchar *pri_db_filename = NULL;
_cleanup_free_ gchar *fil_db_filename = NULL;