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




commit a29bd918cee080420a683cde3c7f174283573a0d
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 314a8fc7..4446950a 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:
@@ -171,7 +171,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]