PrepareBinhostUploads: Finish updating package index before deduplication

BUG=None
TEST=run_tests

Change-Id: I4c070450eef94d7ef9b00152795dffe9449ba3d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1659339
Reviewed-by: David Burger <dburger@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/binhost.py b/api/controller/binhost.py
index d22112f..ec48909 100644
--- a/api/controller/binhost.py
+++ b/api/controller/binhost.py
@@ -99,9 +99,9 @@
   # Read all packages and update the index. The index must be uploaded to the
   # binhost for Portage to use it, so include it in upload_targets.
   uploads_dir = binhost.GetPrebuiltsRoot(chroot, sysroot, build_target)
-  upload_targets = binhost.GetPrebuiltsFiles(uploads_dir, package_index_paths)
   index_path = binhost.UpdatePackageIndex(uploads_dir, upload_uri, upload_path,
                                           sudo=True)
+  upload_targets = binhost.GetPrebuiltsFiles(uploads_dir, package_index_paths)
   assert index_path.startswith(uploads_dir), (
       'expected index_path to start with uploads_dir')
   upload_targets.append(index_path[len(uploads_dir):])