[Rpm-metadata] createrepo/utils.py

valentina at osuosl.org valentina at osuosl.org
Mon Jan 4 14:18:54 UTC 2016


 createrepo/utils.py |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 0904d34bc9286b903b79f8fc42afc3f7cb63a9ad
Author: Valentina Mukhamedzhanova <vmukhame at redhat.com>
Date:   Mon Jan 4 15:18:21 2016 +0100

    Make sure filename doesn't already contain a checksum. BZ#1104840

diff --git a/createrepo/utils.py b/createrepo/utils.py
index b0d92ec..697728b 100644
--- a/createrepo/utils.py
+++ b/createrepo/utils.py
@@ -18,6 +18,7 @@
 
 import os
 import os.path
+import re
 import sys
 import bz2
 import gzip
@@ -173,6 +174,9 @@ def checksum_and_rename(fn_path, sumtype='sha256'):
     csum = misc.checksum(sumtype, fn_path)
     fn = os.path.basename(fn_path)
     fndir = os.path.dirname(fn_path)
+    fn_match = re.match(r'[0-9A-Fa-f]{32,128}-(.+)', fn)
+    if fn_match:
+        fn = fn_match.groups()[0]
     csum_fn = csum + '-' + fn
     csum_path = os.path.join(fndir, csum_fn)
     os.rename(fn_path, csum_path)


More information about the Rpm-metadata mailing list