]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 12 Jun 2023 17:59:22 +0000 (19:59 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 12 Jun 2023 17:59:22 +0000 (19:59 +0200)
- ops, don't double-fetch a single row, causing 2nd invocation of fetchone()
  to return None as the first one already fetched it

fba/instances.py

index e8db2290309d38d5c64ec94b239773900209ceb4..a6109dfc19c7c1867ce75c4531f3a29915de4602 100644 (file)
@@ -340,7 +340,7 @@ def is_recent(domain: str) -> bool:
     return recently
 
 def deobscure(char: str, domain: str, blocked_hash: str = None) -> tuple:
-    #print(f"DEBUG: char='{char}',domain='{domain}',blocked_hash='{blocked_hash}' - CALLED!")
+    # DEBUG: print(f"DEBUG: char='{char}',domain='{domain}',blocked_hash='{blocked_hash}' - CALLED!")
     if not isinstance(char, str):
         raise ValueError(f"Parameter char[]='{type(char)}' is not 'str'")
     elif char == "":
@@ -353,19 +353,25 @@ def deobscure(char: str, domain: str, blocked_hash: str = None) -> tuple:
         raise ValueError(f"Parameter blocked_hash[]='{type(blocked_hash)}' is not 'str'")
 
     if isinstance(blocked_hash, str):
+        # DEBUG: print(f"DEBUG: Looking up blocked_hash='{blocked_hash}' ...")
         fba.cursor.execute(
             "SELECT domain, origin, nodeinfo_url FROM instances WHERE hash = ? LIMIT 1", [blocked_hash]
         )
 
-        if fba.cursor.fetchone() is None:
-            #print(f"DEBUG: blocked_hash='{blocked_hash}' not found, trying domain='{domain}' ...")
+        row = fba.cursor.fetchone()
+        # DEBUG: print(f"DEBUG: row[]='{type(row)}'")
+
+        if row is None:
+            # DEBUG: print(f"DEBUG: blocked_hash='{blocked_hash}' not found, trying domain='{domain}' ...")
             return deobscure(char, domain)
     else:
+        # DEBUG: print(f"DEBUG: Looking up domain='{domain}' ...")
         fba.cursor.execute(
             "SELECT domain, origin, nodeinfo_url FROM instances WHERE domain LIKE ? ORDER BY rowid LIMIT 1", [domain.replace(char, "_")]
         )
 
-    row = fba.cursor.fetchone()
+        row = fba.cursor.fetchone()
+        # DEBUG: print(f"DEBUG: row[]='{type(row)}'")
 
-    #print(f"DEBUG: row[]='{type(row)}' - EXIT!")
+    # DEBUG: print(f"DEBUG: row[]='{type(row)}' - EXIT!")
     return row