[gimp-web/wip/Jehan/fix-ci] tools: one more optimization of gimp-check-mirrors script.



commit 4831bcb4a06650cb7ed525b8ac25ddbe370b275f
Author: Jehan <jehan girinstud io>
Date:   Sun May 1 19:30:54 2022 +0200

    tools: one more optimization of gimp-check-mirrors script.
    
    Actually we don't need to wait for the original file checksums to be
    completed first before starting to download and compute the checksums of
    the mirror files. Let's just pass the concurrent.futures.Future object
    to the mirror check threads and let these wait for us if the original
    checksum was not finished yet.

 tools/downloads/gimp-check-mirrors.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/tools/downloads/gimp-check-mirrors.py b/tools/downloads/gimp-check-mirrors.py
index a1e6e2c8..aa9789a2 100755
--- a/tools/downloads/gimp-check-mirrors.py
+++ b/tools/downloads/gimp-check-mirrors.py
@@ -93,12 +93,12 @@ def find_latest():
 
     return latest
 
-def verify_remote(uri, checksum):
+def verify_remote(uri, future):
   success     = False
   status      = None
   checksum_ok = None
   try:
-    if checksum is not None:
+    if future is not None:
       with requests.get(uri, stream=True) as response:
         m = hashlib.sha256()
         # I don't think the chunk_size is useful, since docs
@@ -108,7 +108,7 @@ def verify_remote(uri, checksum):
         # a reasonable chunk size to process.
         for line in response.iter_content(chunk_size=65536, decode_unicode=False):
           m.update(line)
-        if m.digest() == checksum:
+        if m.digest() == future.result():
           checksum_ok = True
           success = True
         else:
@@ -172,7 +172,7 @@ with concurrent.futures.ThreadPoolExecutor(max_workers=None) as executor:
 
     origin_checksum = None
     if args.verify_checksum:
-      origin_checksum = origin_checksums[local_uri].result()
+      origin_checksum = origin_checksums[local_uri]
 
     with fileinput.input(files=(args.mirrorsfile), mode='r') as f:
       for line in f:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]