File 9465da41-urlfetcher-Deal-with-file-in-_LocalURLFetcher.patch of Package virt-manager.18136
Subject: urlfetcher: Deal with 'file://' in _LocalURLFetcher()
From: Fabiano FidĂȘncio fidencio@redhat.com Tue Sep 24 14:26:43 2019 +0200
Date: Wed Oct 2 11:58:34 2019 -0400:
Git: 9465da4174e778e7607908f18d74fd8aa2cba2fe
osinfo-db may contain files pointing to local paths, which will have the
format 'file:///usr/share/...'.
With the current code, virt-install would just bail as it doesn't
understand the 'file://' schema. Let's start using urllib (which is
already imported in the very same file) and parse the URL so both
'file:///usr/share/...' and '/usr/share/...' would work.
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
diff --git a/virtinst/install/urlfetcher.py b/virtinst/install/urlfetcher.py
index 6084bf01..e52efc8e 100644
--- a/virtinst/install/urlfetcher.py
+++ b/virtinst/install/urlfetcher.py
@@ -365,11 +365,13 @@ class _LocalURLFetcher(_URLFetcher):
For grabbing files from a local directory
"""
def _hasFile(self, url):
- return os.path.exists(url)
+ parsed = urllib.parse.urlparse(url)
+ return os.path.exists(parsed.path)
def _grabber(self, url):
- urlobj = open(url, "rb")
- size = os.path.getsize(url)
+ parsed = urllib.parse.urlparse(url)
+ urlobj = open(parsed.path, "rb")
+ size = os.path.getsize(parsed.path)
return urlobj, size