allow already-compressed metadata files to work and not be double-compressed
authorSeth Vidal <skvidal@fedoraproject.org>
Thu, 23 Oct 2008 20:47:41 +0000 (16:47 -0400)
committerSeth Vidal <skvidal@fedoraproject.org>
Thu, 23 Oct 2008 20:47:41 +0000 (16:47 -0400)
modifyrepo.py

index b86f53ebe152d9d4bac969415378272a617a1f09..558ec0894e6dcbe6ec2b359672085b943e68a4fb 100755 (executable)
@@ -62,7 +62,10 @@ class RepoMetadata:
             mdname = 'updateinfo.xml'
         elif isinstance(metadata, str):
             if os.path.exists(metadata):
-                oldmd = file(metadata, 'r')
+                if metadata.endswith('.gz'):
+                    oldmd = GzipFile(filename=metadata, mode='rb')
+                else:
+                    oldmd = file(metadata, 'r')
                 md = oldmd.read()
                 oldmd.close()
                 mdname = os.path.basename(metadata)
@@ -72,7 +75,8 @@ class RepoMetadata:
             raise Exception('invalid metadata type')
 
         ## Compress the metadata and move it into the repodata
-        mdname += '.gz'
+        if not mdname.endswith('.gz'):
+            mdname += '.gz'
         mdtype = mdname.split('.')[0]
         destmd = os.path.join(self.repodir, mdname)
         newmd = GzipFile(filename=destmd, mode='wb')