From eb9c50e3c4a27c7a58a96ad45c371a9ab64cd85f Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Wed, 6 Nov 2013 15:12:39 +0100 Subject: [PATCH] repomd: In new RepomdRecords set the open_size to -1. --- src/repomd.c | 7 +++++-- tests/python/tests/test_repomdrecord.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/repomd.c b/src/repomd.c index 1f3b98e..21bf4d6 100644 --- a/src/repomd.c +++ b/src/repomd.c @@ -54,6 +54,8 @@ cr_repomd_record_new(const char *type, const char *path) cr_RepomdRecord *md = g_malloc0(sizeof(*md)); md->chunk = g_string_chunk_new(128); md->type = cr_safe_string_chunk_insert(md->chunk, type); + md->size_open = -1; + if (path) { gchar *filename = cr_get_filename(path); gchar *location_href = g_strconcat(LOCATION_HREF_PREFIX, filename, NULL); @@ -61,6 +63,7 @@ cr_repomd_record_new(const char *type, const char *path) md->location_href = g_string_chunk_insert(md->chunk, location_href); g_free(location_href); } + return md; } @@ -235,7 +238,7 @@ cr_repomd_record_fill(cr_RepomdRecord *md, // Compute checksum of non compressed content and its size - if (!md->checksum_open_type || !md->checksum_open || !md->size_open) { + if (!md->checksum_open_type || !md->checksum_open || md->size_open == -1) { cr_CompressionType com_type = cr_detect_compression(path, &tmp_err); if (tmp_err) { int code = tmp_err->code; @@ -261,7 +264,7 @@ cr_repomd_record_fill(cr_RepomdRecord *md, md->checksum_open_type = g_string_chunk_insert(md->chunk, checksum_str); md->checksum_open = g_string_chunk_insert(md->chunk, open_stat->checksum); - if (!md->size_open) + if (md->size_open == -1) md->size_open = open_stat->size; g_free(open_stat->checksum); g_free(open_stat); diff --git a/tests/python/tests/test_repomdrecord.py b/tests/python/tests/test_repomdrecord.py index f5b4b6c..9f03a87 100644 --- a/tests/python/tests/test_repomdrecord.py +++ b/tests/python/tests/test_repomdrecord.py @@ -37,7 +37,7 @@ class TestCaseRepomdRecord(unittest.TestCase): self.assertEqual(rec.checksum_open_type, None) self.assertEqual(rec.timestamp, 0) self.assertEqual(rec.size, 0) - self.assertEqual(rec.size_open, 0) + self.assertEqual(rec.size_open, -1) self.assertEqual(rec.db_ver, 0) rec.fill(cr.SHA256) -- 2.7.4