Always pass file name to download_file()

Move the file name decision to get_packages() when a file name is not
specified in the package source file.
This commit is contained in:
Dor Askayo 2023-01-13 19:38:28 +02:00
parent 38e5dfe35b
commit 425beee8dd
1 changed files with 7 additions and 6 deletions

View File

@ -71,13 +71,10 @@ actual: {readable_hash}\n\
When in doubt, try deleting the file in question -- it will be downloaded again when running \ When in doubt, try deleting the file in question -- it will be downloaded again when running \
this script the next time") this script the next time")
def download_file(self, url, directory, file_name=None): def download_file(self, url, directory, file_name):
""" """
Download a single source archive. Download a single source archive.
""" """
# Automatically determine file name based on URL.
if file_name is None:
file_name = os.path.basename(url)
abs_file_name = os.path.join(directory, file_name) abs_file_name = os.path.join(directory, file_name)
# Create a directory for downloaded file # Create a directory for downloaded file
@ -110,10 +107,14 @@ this script the next time")
with open(sourcef, "r", encoding="utf_8") as sources: with open(sourcef, "r", encoding="utf_8") as sources:
for line in sources.readlines(): for line in sources.readlines():
line = line.strip().split(" ") line = line.strip().split(" ")
if len(line) > 2: if len(line) > 2:
path = self.download_file(line[0], self.cache_dir, line[2]) file_name = line[2]
else: else:
path = self.download_file(line[0], self.cache_dir) # Automatically determine file name based on URL.
file_name = os.path.basename(line[0])
path = self.download_file(line[0], self.cache_dir, file_name)
self.check_file(path, line[1]) self.check_file(path, line[1])
def make_initramfs(self): def make_initramfs(self):