From: Michael Tremer Date: Tue, 11 Feb 2025 13:58:17 +0000 (+0000) Subject: backend: Extend path to URL function to support mirrors X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b84457443156bdd7d85b6127bf2b992a4518917;p=pbs.git backend: Extend path to URL function to support mirrors Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index 428a84bc..fd866512 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -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): """