From: James Antill Date: Wed, 13 May 2009 22:36:50 +0000 (-0400) Subject: Add open-size and size fo *_db MD. Fix file to stat for *.xml.gz size X-Git-Tag: upstream/0.9.9~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3beb0459cdeaa446b074726f1f33928a4d260cb7;p=tools%2Fcreaterepo.git Add open-size and size fo *_db MD. Fix file to stat for *.xml.gz size --- diff --git a/createrepo/__init__.py b/createrepo/__init__.py index fff1215..36bb350 100644 --- a/createrepo/__init__.py +++ b/createrepo/__init__.py @@ -814,7 +814,12 @@ class MetaDataGenerator: complete_path = os.path.join(repopath, rpm_file) zfo = _gzipOpen(complete_path) - uncsum = misc.checksum(sumtype, zfo) + # This is misc.checksum() done locally so we can get the size too. + data = misc.Checksums([sumtype]) + while data.read(zfo, 2**16): + pass + uncsum = data.hexdigest(sumtype) + unsize = len(data) zfo.close() csum = misc.checksum(sumtype, complete_path) timestamp = os.stat(complete_path)[8] @@ -853,6 +858,8 @@ class MetaDataGenerator: # csum the compressed file db_compressed_sums[ftype] = misc.checksum(sumtype, result_compressed) + # timestamp+size the uncompressed file + un_stat = os.stat(resultpath) # remove the uncompressed file os.unlink(resultpath) @@ -865,8 +872,8 @@ class MetaDataGenerator: result_compressed = csum_result_compressed compressed_name = csum_compressed_name - # timestamp the compressed file - db_timestamp = os.stat(result_compressed)[8] + # timestamp+size the compressed file + db_stat = os.stat(result_compressed) # add this data as a section to the repomdxml db_data_type = '%s_db' % ftype @@ -883,7 +890,9 @@ class MetaDataGenerator: db_compressed_sums[ftype]) checksum.newProp('type', sumtype) db_tstamp = data.newChild(None, 'timestamp', - str(db_timestamp)) + str(db_stat.st_mtime)) + data.newChild(None, 'size', str(db_stat.st_size)) + data.newChild(None, 'open-size', str(un_stat.st_size)) unchecksum = data.newChild(None, 'open-checksum', db_csums[ftype]) unchecksum.newProp('type', sumtype) @@ -901,8 +910,9 @@ class MetaDataGenerator: checksum = data.newChild(None, 'checksum', csum) checksum.newProp('type', sumtype) timestamp = data.newChild(None, 'timestamp', str(timestamp)) - size = os.stat(os.path.join(repopath, file)) + size = os.stat(os.path.join(repopath, rpm_file)) data.newChild(None, 'size', str(size.st_size)) + data.newChild(None, 'open-size', str(unsize)) unchecksum = data.newChild(None, 'open-checksum', uncsum) unchecksum.newProp('type', sumtype) location = data.newChild(None, 'location', None)