Updated for filename

This commit is contained in:
Dimitris Zlatanidis 2023-04-26 21:27:05 +03:00
parent 0d5d779722
commit a7d7c958ee

View file

@ -4,8 +4,8 @@
import shutil
from typing import Union
from pathlib import Path
from urllib.parse import unquote
from multiprocessing import Process
from urllib.parse import unquote, urlparse
from slpkg.configs import Configs
from slpkg.utilities import Utilities
@ -46,7 +46,8 @@ class Downloader(Configs):
def tool(self, url: str) -> None:
""" Downloader tools wget, wget2, curl and lftp. """
command: str = ''
filename: str = url.split('/')[-1]
path: str = urlparse(url).path
filename: str = Path(path).name
if url.startswith('file'):
shutil.copy2(url[7:], self.tmp_slpkg)
@ -69,8 +70,9 @@ class Downloader(Configs):
def check_if_downloaded(self, url: str) -> None:
""" Checks if the file downloaded. """
url: str = unquote(url)
file: str = url.split('/')[-1]
path_file: Path = Path(self.path, file)
path: str = urlparse(url).path
filename: str = Path(path).name
path_file: Path = Path(self.path, filename)
if not path_file.exists():
self.errors.raise_error_message(f"Download the '{url}' file", exit_status=20)