From 80f89004b9b22d4d41e99a744b14cbd7aa6870e0 Mon Sep 17 00:00:00 2001 From: godofredoc Date: Mon, 13 Nov 2023 14:14:58 -0800 Subject: [PATCH] Fix fuchsia upload symbols. (flutter/engine#47938) The fuchsia bucket does not have a delete ACL which is required to replace files that already exist. This change skips uploading the file if it already exists. Bug: https://github.com/flutter/flutter/issues/126461 Bug: https://github.com/flutter/flutter/issues/135189 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../tools/fuchsia/upload_to_symbol_server.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/tools/fuchsia/upload_to_symbol_server.py b/engine/src/flutter/tools/fuchsia/upload_to_symbol_server.py index 50aceef874..d67fd4c118 100755 --- a/engine/src/flutter/tools/fuchsia/upload_to_symbol_server.py +++ b/engine/src/flutter/tools/fuchsia/upload_to_symbol_server.py @@ -32,6 +32,19 @@ def remote_filename(exec_path): return ''.join(parts[-2:]) +def exists_remotely(remote_path): + gsutil = os.path.join(os.environ['DEPOT_TOOLS'], 'gsutil.py') + command = ['python3', gsutil, '--', 'stat', remote_path] + process = subprocess.Popen( + command, stderr=subprocess.PIPE, stdout=subprocess.PIPE + ) + stdout, stderr = process.communicate() + return_code = process.wait() + if return_code == 0: + print('%s exists - skipping copy' % remote_path) + return return_code == 0 + + def process_symbols(should_upload, symbol_dir): full_path = os.path.join(BUILD_ROOT_DIR, symbol_dir) @@ -50,9 +63,9 @@ def process_symbols(should_upload, symbol_dir): FUCHSIA_ARTIFACTS_BUCKET_NAME, FUCHSIA_ARTIFACTS_DEBUG_NAMESPACE, remote_filename(file) ) - if should_upload: + if should_upload and not exists_remotely(remote_path): gsutil = os.path.join(os.environ['DEPOT_TOOLS'], 'gsutil.py') - command = ['python3', gsutil, '--', 'cp', gsutil, file, remote_path] + command = ['python3', gsutil, '--', 'cp', file, remote_path] subprocess.check_call(command) else: print(remote_path)