commit: 38e5dfe35b1b123d0a5bed390aa088df2fb14947
parent 693d01dc1b9d3b4d854ae02ccf156f6dfa89a7e9
Author: Dor Askayo <dor.askayo@gmail.com>
Date: Fri, 13 Jan 2023 15:47:06 +0200
Pass destination directory to download_file()
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/sysgeneral.py b/lib/sysgeneral.py
@@ -3,7 +3,7 @@
This file contains a few functions to be shared by all Sys* classes
"""
-# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
+# SPDX-FileCopyrightText: 2022-2023 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-License-Identifier: GPL-3.0-or-later
@@ -71,18 +71,18 @@ 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, file_name=None):
+ def download_file(self, url, directory, file_name=None):
"""
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(self.cache_dir, file_name)
+ abs_file_name = os.path.join(directory, file_name)
- # Create a cache directory for downloaded sources
- if not os.path.isdir(self.cache_dir):
- os.mkdir(self.cache_dir)
+ # Create a directory for downloaded file
+ if not os.path.isdir(directory):
+ os.mkdir(directory)
# Actually download the file
headers = {
@@ -111,9 +111,9 @@ this script the next time")
for line in sources.readlines():
line = line.strip().split(" ")
if len(line) > 2:
- path = self.download_file(line[0], line[2])
+ path = self.download_file(line[0], self.cache_dir, line[2])
else:
- path = self.download_file(line[0])
+ path = self.download_file(line[0], self.cache_dir)
self.check_file(path, line[1])
def make_initramfs(self):