commit: 425beee8dda68683fa2c34830a1e1f0ecf1af953
parent 38e5dfe35b1b123d0a5bed390aa088df2fb14947
Author: Dor Askayo <dor.askayo@gmail.com>
Date: Fri, 13 Jan 2023 19:38:28 +0200
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.
Diffstat:
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/sysgeneral.py b/lib/sysgeneral.py
@@ -71,13 +71,10 @@ actual: {readable_hash}\n\
When in doubt, try deleting the file in question -- it will be downloaded again when running \
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.
"""
- # 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)
# Create a directory for downloaded file
@@ -110,10 +107,14 @@ this script the next time")
with open(sourcef, "r", encoding="utf_8") as sources:
for line in sources.readlines():
line = line.strip().split(" ")
+
if len(line) > 2:
- path = self.download_file(line[0], self.cache_dir, line[2])
+ file_name = line[2]
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])
def make_initramfs(self):