]> git.ipfire.org Git - pbs.git/commitdiff
backend: Extend path to URL function to support mirrors
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Feb 2025 13:58:17 +0000 (13:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Feb 2025 13:58:17 +0000 (13:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py

index 428a84bc8b7d62b86a8be454c865eecf91c84dec..fd866512234df9f7ff8460fe3825a1d870b92086 100644 (file)
@@ -179,16 +179,19 @@ class Backend(object):
                # Make the URL
                return urllib.parse.urljoin(baseurl, url)
 
-       def path_to_url(self, path):
+       def path_to_url(self, path, mirrored=False):
                """
                        Takes a path to a file on the file system and converts it into a URL
                """
-               # Path to package
-               path = os.path.join(
-                       "files", os.path.relpath(path, self.basepath),
-               )
+               # Make the path relative
+               path = self.relpath(path)
+
+               # Send to the downloads load balancer
+               if mirrored:
+                       return self.url_to("downloads", path)
 
-               return self.url_to(path)
+               # Send them to the local file store
+               return self.url_to("files", path)
 
        def pakfire(self, *args, **kwargs):
                """