From 7789b443e76dc25d4a40df6c2a0cac6dde09d93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 18 Aug 2024 14:04:03 +0200 Subject: [PATCH 1/2] Fix #13027 (daca@home larger result data must be uploaded in chunks) --- tools/donate-cpu-server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index cdf79fa2f4f..9256d93049f 100755 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -26,7 +26,7 @@ # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -SERVER_VERSION = "1.3.55" +SERVER_VERSION = "1.3.56" OLD_VERSION = '2.14.0' @@ -1334,7 +1334,7 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa continue elif cmd.startswith('write\nftp://') or cmd.startswith('write\nhttp://'): t_start = time.perf_counter() - data = read_data(connection, cmd, pos_nl, max_data_size=2.5 * 1024 * 1024, check_done=True, cmd_name='write') + data = read_data(connection, cmd, pos_nl, max_data_size=10 * 1024 * 1024, check_done=True, cmd_name='write') if data is None: continue From 256fe317f02c50c586e3ef66e6eb3e8492a0400c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 18 Aug 2024 14:30:23 +0200 Subject: [PATCH 2/2] Remove result if it's too large --- tools/donate-cpu-server.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index 9256d93049f..b35cd3da702 100755 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -1254,9 +1254,8 @@ def read_data(connection, cmd, pos_nl, max_data_size, check_done, cmd_name, time if data and (len(data) >= max_data_size): print_ts('Maximum allowed data ({} bytes) exceeded ({}).'.format(max_data_size, cmd_name)) - data = None - if data and check_done and not data.endswith('\nDONE'): + elif data and check_done and not data.endswith('\nDONE'): print_ts('Incomplete data received ({}).'.format(cmd_name)) data = None @@ -1334,9 +1333,10 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa continue elif cmd.startswith('write\nftp://') or cmd.startswith('write\nhttp://'): t_start = time.perf_counter() - data = read_data(connection, cmd, pos_nl, max_data_size=10 * 1024 * 1024, check_done=True, cmd_name='write') + data = read_data(connection, cmd, pos_nl, max_data_size=1024 * 1024, check_done=True, cmd_name='write') if data is None: continue + truncated_data = len(data) >= 1024 * 1024 pos = data.find('\n') if pos == -1: @@ -1376,6 +1376,10 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa print_ts('Unexpected old version. Ignoring result data.') continue filename = os.path.join(resultPath, res.group(1)) + if truncated_data: + print_ts('Data is too large. Removing result.') + os.remove(filename) + continue with open(filename, 'wt') as f: f.write(strDateTime() + '\n' + data) # track latest added results.. @@ -1393,6 +1397,7 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa data = read_data(connection, cmd, pos_nl, max_data_size=7 * 1024 * 1024, check_done=True, cmd_name='write_info') if data is None: continue + truncated_data = len(data) >= 7 * 1024 * 1024 pos = data.find('\n') if pos == -1: @@ -1418,6 +1423,10 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa if not os.path.exists(info_path): os.mkdir(info_path) filename = info_path + '/' + res.group(1) + if truncated_data: + print_ts('Data is too large. Removing result.') + os.remove(filename) + continue with open(filename, 'wt') as f: f.write(strDateTime() + '\n' + data) print_ts('write_info finished for {} ({} bytes / {}s)'.format(res.group(1), len(data), (time.perf_counter() - t_start)))