浏览代码

Improve upload_to_google_storage.py missing file handling

When there are missing input files, upload_to_google_storage.py
should not display 'Success'.

Bug: 920654
Change-Id: I1bc7ba6e8eb48ea28b634da01e1be9a80af7b719
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2647870
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: John Chen <johnchen@chromium.org>
John Chen 4 年之前
父节点
当前提交
680a6c37a0
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      upload_to_google_storage.py

+ 5 - 0
upload_to_google_storage.py

@@ -167,9 +167,11 @@ def upload_to_google_storage(
   # We want to hash everything in a single thread since its faster.
   # The bottleneck is in disk IO, not CPU.
   hashing_start = time.time()
+  has_missing_files = False
   for filename in input_filenames:
     if not os.path.exists(filename):
       stdout_queue.put('Main> Error: %s not found, skipping.' % filename)
+      has_missing_files = True
       continue
     if os.path.exists('%s.sha1' % filename) and skip_hashing:
       stdout_queue.put(
@@ -208,6 +210,9 @@ def upload_to_google_storage(
     max_ret_code = max(ret_code, max_ret_code)
     if message:
       print(message, file=sys.stderr)
+  if has_missing_files:
+    print('One or more input files missing', file=sys.stderr)
+    max_ret_code = max(1, max_ret_code)
 
   if not max_ret_code:
     print('Success!')