From df0a6d9bf467f04453f91c9bfa9c2875a1d17b18 Mon Sep 17 00:00:00 2001 From: Dmitry Potepalov Date: Tue, 27 Aug 2024 16:31:59 +0200 Subject: [PATCH] seek the temp file when copying between storages Rohmu download functions do not promise that the temporary file will be immediately readable after get_contents_to_fileobj exits. Seek it to the beginning of the temporary file before reading and uploading. --- astacus/coordinator/plugins/clickhouse/object_storage.py | 1 + 1 file changed, 1 insertion(+) diff --git a/astacus/coordinator/plugins/clickhouse/object_storage.py b/astacus/coordinator/plugins/clickhouse/object_storage.py index 8a69ee07..e671b007 100644 --- a/astacus/coordinator/plugins/clickhouse/object_storage.py +++ b/astacus/coordinator/plugins/clickhouse/object_storage.py @@ -119,6 +119,7 @@ def _copy_via_local_filesystem( for keys_copied, key in enumerate(keys): with tempfile.TemporaryFile(dir=copy_config.temporary_directory) as temp_file: metadata = source.get_contents_to_fileobj(key, temp_file) + temp_file.seek(0) target.store_file_object(key, temp_file, metadata) if stats: stats.gauge(