#120 Make lookaside cache work with SIG dist-git using "modern" layout
Opened 7 days ago by nforro. Modified 7 days ago
centos/ nforro/centpkg sig-lookaside  into  develop

file modified
+16 -6
@@ -54,7 +54,7 @@ 

          javabranchre = r"openjdk-portable-centos-(?P<centosversion>\d+)"

          oldbranchre = r"(?P<signame>\w+)(?P<centosversion>\d)"

          rhelmatch = re.search(rhelbranchre, branchtext)

-         sigmatch = re.match(sigtobranchre, branchtext)

+         sigmatch = re.search(sigtobranchre, branchtext)

          distromatch = re.match(distrobranchre, branchtext)

          javamatch = re.match(javabranchre, branchtext)

          oldbranchmatch = re.match(oldbranchre, branchtext)
@@ -180,11 +180,21 @@ 

      @cached_property

      def lookasidecache(self):

          if self.layout.sources_file_template == "sources":

-             return StreamLookasideCache(

-                 self.lookasidehash,

-                 self.lookaside,

-                 self.lookaside_cgi,

-             )

+             if self.distgitdir.sigbranch:

+                 return SIGLookasideCache(

+                     self.lookasidehash,

+                     self.lookaside,

+                     self.lookaside_cgi,

+                     self.repo_name,

+                     branch=None,

+                     client_cert=os.path.expanduser("~/.centos.cert"),

+                 )

+             else:

+                 return StreamLookasideCache(

+                     self.lookasidehash,

+                     self.lookaside,

+                     self.lookaside_cgi,

+                 )

          else:

              if self.distgitdir.sigbranch:

                  return SIGLookasideCache(

file modified
+18 -3
@@ -240,7 +240,10 @@ 

          self.branch = branch

  

      def get_download_url(self, name, filename, hash, hashtype=None, **kwargs):

-         download_path = "%(name)s/%(branch)s/%(hash)s"

+         if self.branch:

+             download_path = "%(name)s/%(branch)s/%(hash)s"

+         else:

+             download_path = self.download_path

          if "/" in name:

              real_name = name.split("/")[-1]

          else:
@@ -264,6 +267,9 @@ 

          :param str filename: The name of the file to check for.

          :param str hash: The known good hash of the file.

          """

+         if not self.branch:

+             return super(SIGLookasideCache, self).remote_file_exists_head(

+                 name, filename, hash, self.hashtype)

  

          # RHEL 7 ships pycurl that does not accept unicode. When given unicode

          # type it would explode with "unsupported second type in tuple". Let's
@@ -325,7 +331,7 @@ 

          self.log.debug(output)

          raise UploadError("Error checking for %s at %s" % (filename, self.upload_url))

  

-     def upload(self, name, filepath, hash):

+     def upload(self, name, filename, hash, offline=False):

          """Upload a source file

  

          :param str name: The name of the module. (usually the name of the SRPM)
@@ -334,6 +340,15 @@ 

          :param str filepath: The full path to the file to upload.

          :param str hash: The known good hash of the file.

          """

+         if "/" in name:

+             real_name = name.split("/")[-1]

+         else:

+             real_name = name

+ 

+         if not self.branch:

+             return super(SIGLookasideCache, self).upload(

+                 real_name, filename, hash)

+ 

          filename = os.path.basename(filepath)

  

          if self.remote_file_exists(name, filename, hash):
@@ -342,7 +357,7 @@ 

  

          self.log.info("Uploading: %s", filepath)

          post_data = [

-             ("name", name),

+             ("name", real_name),

              ("%ssum" % self.hashtype, hash),

              ("file", (pycurl.FORM_FILE, filepath)),

          ]

This makes centpkg-sig sources and centpkg-sig new-sources work in SIG dist-git repos using the "modern" layout with a sources file.

Can you give an example where this is needed, and so I can test that it fixes the problem.