From 1fda453bbd5d04363a7c9ce10b495231e09c7763 Mon Sep 17 00:00:00 2001 From: Neocky Date: Thu, 9 Feb 2023 20:18:21 +0100 Subject: [PATCH 1/3] Fixed issue with ftp temp folder The ftp files wouldn't get downloaded in the TempSFTPFolder and this would result in a crash --- src/handlers/handle_ftp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/handlers/handle_ftp.py b/src/handlers/handle_ftp.py index df84be9..2abb289 100644 --- a/src/handlers/handle_ftp.py +++ b/src/handlers/handle_ftp.py @@ -136,22 +136,24 @@ def ftp_list_files_in_server_root(ftp): rich_print_error("Error: [FTP]: No Serverjar was found.") -def ftp_download_file(ftp, path_download, file) -> None: +def ftp_download_file(ftp, file) -> None: """ Download a file of the ftp server :param ftp: ftp connection - :param path_download: Path to save downloaded file to :param file: File to download :returns None """ config_values = config_value() ftp.cwd(config_values.remote_plugin_folder_on_server) + current_directory = os.getcwd() + os.chdir('TempSFTPFolder') filedata = open(path_download,'wb') ftp.retrbinary('RETR '+file, filedata.write) filedata.close() ftp.quit() + os.chdir(current_directory) return None From a9bac687c8e48ac9bbf568e6224915205b51d540 Mon Sep 17 00:00:00 2001 From: Neocky Date: Thu, 9 Feb 2023 20:54:03 +0100 Subject: [PATCH 2/3] Revert false FTP fix and solve it --- src/handlers/handle_ftp.py | 5 +---- src/plugin/plugin_updatechecker.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/handlers/handle_ftp.py b/src/handlers/handle_ftp.py index 2abb289..c2f4e18 100644 --- a/src/handlers/handle_ftp.py +++ b/src/handlers/handle_ftp.py @@ -136,7 +136,7 @@ def ftp_list_files_in_server_root(ftp): rich_print_error("Error: [FTP]: No Serverjar was found.") -def ftp_download_file(ftp, file) -> None: +def ftp_download_file(ftp, path_download, file) -> None: """ Download a file of the ftp server @@ -147,13 +147,10 @@ def ftp_download_file(ftp, file) -> None: """ config_values = config_value() ftp.cwd(config_values.remote_plugin_folder_on_server) - current_directory = os.getcwd() - os.chdir('TempSFTPFolder') filedata = open(path_download,'wb') ftp.retrbinary('RETR '+file, filedata.write) filedata.close() ftp.quit() - os.chdir(current_directory) return None diff --git a/src/plugin/plugin_updatechecker.py b/src/plugin/plugin_updatechecker.py index 9423791..ed5a8e4 100644 --- a/src/plugin/plugin_updatechecker.py +++ b/src/plugin/plugin_updatechecker.py @@ -225,8 +225,8 @@ def egg_cracking_jar(plugin_file_name: str) -> str: case "ftp": path_temp_plugin_folder = create_temp_plugin_folder() connection = ftp_create_connection() - ftp_download_file(connection, plugin_file_name) path_plugin_jar = Path(f"{path_temp_plugin_folder}/{plugin_file_name}") + ftp_download_file(connection, path_plugin_jar, plugin_file_name) case _: path_plugin_folder = config_values.path_to_plugin_folder path_plugin_jar = Path(f"{path_plugin_folder}/{plugin_file_name}") From 3f4380acaeaeebda2e43ea966f04c30307ec50c1 Mon Sep 17 00:00:00 2001 From: Neocky Date: Thu, 9 Feb 2023 20:58:17 +0100 Subject: [PATCH 3/3] Update handle_ftp.py --- src/handlers/handle_ftp.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/handlers/handle_ftp.py b/src/handlers/handle_ftp.py index c2f4e18..df84be9 100644 --- a/src/handlers/handle_ftp.py +++ b/src/handlers/handle_ftp.py @@ -141,6 +141,7 @@ def ftp_download_file(ftp, path_download, file) -> None: Download a file of the ftp server :param ftp: ftp connection + :param path_download: Path to save downloaded file to :param file: File to download :returns None